deeprails 0.17.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +71 -0
- data/README.md +3 -3
- data/lib/deeprails/internal/stream.rb +29 -0
- data/lib/deeprails/internal/transport/base_client.rb +3 -1
- data/lib/deeprails/internal/transport/pooled_net_requester.rb +12 -10
- data/lib/deeprails/internal/type/base_stream.rb +83 -0
- data/lib/deeprails/internal/util.rb +7 -2
- data/lib/deeprails/models/defend_create_workflow_params.rb +14 -1
- data/lib/deeprails/models/defend_response.rb +136 -12
- data/lib/deeprails/models/defend_submit_and_stream_event_params.rb +83 -0
- data/lib/deeprails/models/defend_submit_and_stream_event_response.rb +7 -0
- data/lib/deeprails/models/defend_submit_event_params.rb +52 -16
- data/lib/deeprails/models/defend_update_response.rb +9 -1
- data/lib/deeprails/models/defend_update_workflow_params.rb +131 -5
- data/lib/deeprails/models/file_upload_params.rb +5 -5
- data/lib/deeprails/models/monitor_create_params.rb +14 -1
- data/lib/deeprails/models/monitor_detail_response.rb +56 -17
- data/lib/deeprails/models/monitor_event_detail_response.rb +6 -2
- data/lib/deeprails/models/monitor_submit_event_params.rb +52 -16
- data/lib/deeprails/models/monitor_update_params.rb +46 -5
- data/lib/deeprails/models/workflow_event_detail_response.rb +106 -34
- data/lib/deeprails/models/workflow_event_response.rb +9 -1
- data/lib/deeprails/models.rb +2 -0
- data/lib/deeprails/resources/defend.rb +70 -7
- data/lib/deeprails/resources/files.rb +2 -2
- data/lib/deeprails/resources/monitor.rb +14 -6
- data/lib/deeprails/version.rb +1 -1
- data/lib/deeprails.rb +5 -0
- data/manifest.yaml +1 -0
- data/rbi/deeprails/internal/stream.rbi +20 -0
- data/rbi/deeprails/internal/transport/base_client.rbi +18 -2
- data/rbi/deeprails/internal/type/base_stream.rbi +75 -0
- data/rbi/deeprails/models/defend_create_workflow_params.rbi +21 -0
- data/rbi/deeprails/models/defend_response.rbi +288 -16
- data/rbi/deeprails/models/defend_submit_and_stream_event_params.rbi +148 -0
- data/rbi/deeprails/models/defend_submit_and_stream_event_response.rbi +7 -0
- data/rbi/deeprails/models/defend_submit_event_params.rbi +108 -25
- data/rbi/deeprails/models/defend_update_response.rbi +14 -3
- data/rbi/deeprails/models/defend_update_workflow_params.rbi +298 -4
- data/rbi/deeprails/models/file_upload_params.rbi +9 -6
- data/rbi/deeprails/models/monitor_create_params.rbi +21 -0
- data/rbi/deeprails/models/monitor_detail_response.rbi +107 -26
- data/rbi/deeprails/models/monitor_event_detail_response.rbi +4 -2
- data/rbi/deeprails/models/monitor_submit_event_params.rbi +108 -25
- data/rbi/deeprails/models/monitor_update_params.rbi +107 -4
- data/rbi/deeprails/models/workflow_event_detail_response.rbi +209 -66
- data/rbi/deeprails/models/workflow_event_response.rbi +8 -0
- data/rbi/deeprails/models.rbi +3 -0
- data/rbi/deeprails/resources/defend.rbi +99 -9
- data/rbi/deeprails/resources/files.rbi +3 -3
- data/rbi/deeprails/resources/monitor.rbi +28 -8
- data/sig/deeprails/internal/stream.rbs +9 -0
- data/sig/deeprails/internal/type/base_stream.rbs +38 -0
- data/sig/deeprails/models/defend_create_workflow_params.rbs +7 -0
- data/sig/deeprails/models/defend_response.rbs +114 -8
- data/sig/deeprails/models/defend_submit_and_stream_event_params.rbs +74 -0
- data/sig/deeprails/models/defend_submit_and_stream_event_response.rbs +5 -0
- data/sig/deeprails/models/defend_submit_event_params.rbs +39 -10
- data/sig/deeprails/models/defend_update_response.rbs +10 -3
- data/sig/deeprails/models/defend_update_workflow_params.rbs +103 -1
- data/sig/deeprails/models/file_upload_params.rbs +4 -4
- data/sig/deeprails/models/monitor_create_params.rbs +7 -0
- data/sig/deeprails/models/monitor_detail_response.rbs +36 -9
- data/sig/deeprails/models/monitor_submit_event_params.rbs +39 -10
- data/sig/deeprails/models/monitor_update_params.rbs +45 -1
- data/sig/deeprails/models/workflow_event_detail_response.rbs +100 -27
- data/sig/deeprails/models/workflow_event_response.rbs +5 -0
- data/sig/deeprails/models.rbs +2 -0
- data/sig/deeprails/resources/defend.rbs +20 -0
- data/sig/deeprails/resources/files.rbs +1 -1
- data/sig/deeprails/resources/monitor.rbs +4 -0
- metadata +28 -2
|
@@ -8,13 +8,28 @@ module Deeprails
|
|
|
8
8
|
include Deeprails::Internal::Type::RequestParameters
|
|
9
9
|
|
|
10
10
|
# @!attribute description
|
|
11
|
-
#
|
|
11
|
+
# New description of the monitor.
|
|
12
12
|
#
|
|
13
13
|
# @return [String, nil]
|
|
14
14
|
optional :description, String
|
|
15
15
|
|
|
16
|
+
# @!attribute file_search
|
|
17
|
+
# An array of file IDs to search in the monitor's evaluations. Files must be
|
|
18
|
+
# uploaded via the DeepRails API first.
|
|
19
|
+
#
|
|
20
|
+
# @return [Array<String>, nil]
|
|
21
|
+
optional :file_search, Deeprails::Internal::Type::ArrayOf[String]
|
|
22
|
+
|
|
23
|
+
# @!attribute guardrail_metrics
|
|
24
|
+
# An array of the new guardrail metrics that model input and output pairs will be
|
|
25
|
+
# evaluated on.
|
|
26
|
+
#
|
|
27
|
+
# @return [Array<Symbol, Deeprails::Models::MonitorUpdateParams::GuardrailMetric>, nil]
|
|
28
|
+
optional :guardrail_metrics,
|
|
29
|
+
-> { Deeprails::Internal::Type::ArrayOf[enum: Deeprails::MonitorUpdateParams::GuardrailMetric] }
|
|
30
|
+
|
|
16
31
|
# @!attribute name
|
|
17
|
-
#
|
|
32
|
+
# New name of the monitor.
|
|
18
33
|
#
|
|
19
34
|
# @return [String, nil]
|
|
20
35
|
optional :name, String
|
|
@@ -26,18 +41,44 @@ module Deeprails
|
|
|
26
41
|
# @return [Symbol, Deeprails::Models::MonitorUpdateParams::Status, nil]
|
|
27
42
|
optional :status, enum: -> { Deeprails::MonitorUpdateParams::Status }
|
|
28
43
|
|
|
29
|
-
# @!
|
|
44
|
+
# @!attribute web_search
|
|
45
|
+
# Whether to enable web search for this monitor's evaluations.
|
|
46
|
+
#
|
|
47
|
+
# @return [Boolean, nil]
|
|
48
|
+
optional :web_search, Deeprails::Internal::Type::Boolean
|
|
49
|
+
|
|
50
|
+
# @!method initialize(description: nil, file_search: nil, guardrail_metrics: nil, name: nil, status: nil, web_search: nil, request_options: {})
|
|
30
51
|
# Some parameter documentations has been truncated, see
|
|
31
52
|
# {Deeprails::Models::MonitorUpdateParams} for more details.
|
|
32
53
|
#
|
|
33
|
-
# @param description [String]
|
|
54
|
+
# @param description [String] New description of the monitor.
|
|
55
|
+
#
|
|
56
|
+
# @param file_search [Array<String>] An array of file IDs to search in the monitor's evaluations. Files must be uploa
|
|
57
|
+
#
|
|
58
|
+
# @param guardrail_metrics [Array<Symbol, Deeprails::Models::MonitorUpdateParams::GuardrailMetric>] An array of the new guardrail metrics that model input and output pairs will be
|
|
34
59
|
#
|
|
35
|
-
# @param name [String]
|
|
60
|
+
# @param name [String] New name of the monitor.
|
|
36
61
|
#
|
|
37
62
|
# @param status [Symbol, Deeprails::Models::MonitorUpdateParams::Status] Status of the monitor. Can be `active` or `inactive`. Inactive monitors no lon
|
|
38
63
|
#
|
|
64
|
+
# @param web_search [Boolean] Whether to enable web search for this monitor's evaluations.
|
|
65
|
+
#
|
|
39
66
|
# @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}]
|
|
40
67
|
|
|
68
|
+
module GuardrailMetric
|
|
69
|
+
extend Deeprails::Internal::Type::Enum
|
|
70
|
+
|
|
71
|
+
CORRECTNESS = :correctness
|
|
72
|
+
COMPLETENESS = :completeness
|
|
73
|
+
INSTRUCTION_ADHERENCE = :instruction_adherence
|
|
74
|
+
CONTEXT_ADHERENCE = :context_adherence
|
|
75
|
+
GROUND_TRUTH_ADHERENCE = :ground_truth_adherence
|
|
76
|
+
COMPREHENSIVE_SAFETY = :comprehensive_safety
|
|
77
|
+
|
|
78
|
+
# @!method self.values
|
|
79
|
+
# @return [Array<Symbol>]
|
|
80
|
+
end
|
|
81
|
+
|
|
41
82
|
# Status of the monitor. Can be `active` or `inactive`. Inactive monitors no
|
|
42
83
|
# longer record and evaluate events.
|
|
43
84
|
module Status
|
|
@@ -4,6 +4,11 @@ module Deeprails
|
|
|
4
4
|
module Models
|
|
5
5
|
# @see Deeprails::Resources::Defend#retrieve_event
|
|
6
6
|
class WorkflowEventDetailResponse < Deeprails::Internal::Type::BaseModel
|
|
7
|
+
# @!attribute analysis_of_failures
|
|
8
|
+
#
|
|
9
|
+
# @return [Array<String>]
|
|
10
|
+
required :analysis_of_failures, Deeprails::Internal::Type::ArrayOf[String]
|
|
11
|
+
|
|
7
12
|
# @!attribute evaluation_history
|
|
8
13
|
# History of evaluations for the event.
|
|
9
14
|
#
|
|
@@ -24,12 +29,6 @@ module Deeprails
|
|
|
24
29
|
# @return [String]
|
|
25
30
|
required :event_id, String
|
|
26
31
|
|
|
27
|
-
# @!attribute event_status
|
|
28
|
-
# Status of the event.
|
|
29
|
-
#
|
|
30
|
-
# @return [Symbol, Deeprails::Models::WorkflowEventDetailResponse::EventStatus]
|
|
31
|
-
required :event_status, enum: -> { Deeprails::WorkflowEventDetailResponse::EventStatus }
|
|
32
|
-
|
|
33
32
|
# @!attribute filtered
|
|
34
33
|
# Whether the event was filtered and requires improvement.
|
|
35
34
|
#
|
|
@@ -50,13 +49,29 @@ module Deeprails
|
|
|
50
49
|
required :improvement_action, enum: -> { Deeprails::WorkflowEventDetailResponse::ImprovementAction }
|
|
51
50
|
|
|
52
51
|
# @!attribute improvement_tool_status
|
|
53
|
-
# Status of the improvement tool used to improve the event.
|
|
52
|
+
# Status of the improvement tool used to improve the event. `improvement_required`
|
|
53
|
+
# indicates that the evaluation is complete and the improvement action is needed
|
|
54
|
+
# but is not taking place. `improved` and `improvement_failed` indicate when the
|
|
55
|
+
# improvement action concludes, successfully and unsuccessfully, respectively.
|
|
56
|
+
# `no_improvement_required` means that the first evaluation passed all its
|
|
57
|
+
# metrics!
|
|
54
58
|
#
|
|
55
59
|
# @return [Symbol, Deeprails::Models::WorkflowEventDetailResponse::ImprovementToolStatus, nil]
|
|
56
60
|
required :improvement_tool_status,
|
|
57
61
|
enum: -> { Deeprails::WorkflowEventDetailResponse::ImprovementToolStatus },
|
|
58
62
|
nil?: true
|
|
59
63
|
|
|
64
|
+
# @!attribute key_improvements
|
|
65
|
+
#
|
|
66
|
+
# @return [Array<Object>]
|
|
67
|
+
required :key_improvements, Deeprails::Internal::Type::ArrayOf[Deeprails::Internal::Type::Unknown]
|
|
68
|
+
|
|
69
|
+
# @!attribute status
|
|
70
|
+
# Status of the event.
|
|
71
|
+
#
|
|
72
|
+
# @return [Symbol, Deeprails::Models::WorkflowEventDetailResponse::Status]
|
|
73
|
+
required :status, enum: -> { Deeprails::WorkflowEventDetailResponse::Status }
|
|
74
|
+
|
|
60
75
|
# @!attribute threshold_type
|
|
61
76
|
# Type of thresholds used to evaluate the event.
|
|
62
77
|
#
|
|
@@ -78,8 +93,8 @@ module Deeprails
|
|
|
78
93
|
-> { Deeprails::Internal::Type::HashOf[enum: Deeprails::WorkflowEventDetailResponse::AutomaticHallucinationToleranceLevel] }
|
|
79
94
|
|
|
80
95
|
# @!attribute capabilities
|
|
81
|
-
# Extended AI capabilities available to the event, if any. Can be `web_search
|
|
82
|
-
# and/or `
|
|
96
|
+
# Extended AI capabilities available to the event, if any. Can be `web_search`,
|
|
97
|
+
# `file_search`, and/or `context_awareness`.
|
|
83
98
|
#
|
|
84
99
|
# @return [Array<Deeprails::Models::WorkflowEventDetailResponse::Capability>, nil]
|
|
85
100
|
optional :capabilities,
|
|
@@ -99,25 +114,36 @@ module Deeprails
|
|
|
99
114
|
# @return [Array<Deeprails::Models::WorkflowEventDetailResponse::File>, nil]
|
|
100
115
|
optional :files, -> { Deeprails::Internal::Type::ArrayOf[Deeprails::WorkflowEventDetailResponse::File] }
|
|
101
116
|
|
|
102
|
-
# @!
|
|
117
|
+
# @!attribute max_improvement_attempts
|
|
118
|
+
# The maximum number of improvement attempts to be applied to one event before it
|
|
119
|
+
# is considered failed.
|
|
120
|
+
#
|
|
121
|
+
# @return [Integer, nil]
|
|
122
|
+
optional :max_improvement_attempts, Integer
|
|
123
|
+
|
|
124
|
+
# @!method initialize(analysis_of_failures:, evaluation_history:, evaluation_result:, event_id:, filtered:, improved_model_output:, improvement_action:, improvement_tool_status:, key_improvements:, status:, threshold_type:, workflow_id:, automatic_hallucination_tolerance_levels: nil, capabilities: nil, custom_hallucination_threshold_values: nil, files: nil, max_improvement_attempts: nil)
|
|
103
125
|
# Some parameter documentations has been truncated, see
|
|
104
126
|
# {Deeprails::Models::WorkflowEventDetailResponse} for more details.
|
|
105
127
|
#
|
|
128
|
+
# @param analysis_of_failures [Array<String>]
|
|
129
|
+
#
|
|
106
130
|
# @param evaluation_history [Array<Deeprails::Models::WorkflowEventDetailResponse::EvaluationHistory>] History of evaluations for the event.
|
|
107
131
|
#
|
|
108
132
|
# @param evaluation_result [Hash{Symbol=>Object}] Evaluation result consisting of average scores and rationales for each of the ev
|
|
109
133
|
#
|
|
110
134
|
# @param event_id [String] A unique workflow event ID.
|
|
111
135
|
#
|
|
112
|
-
# @param event_status [Symbol, Deeprails::Models::WorkflowEventDetailResponse::EventStatus] Status of the event.
|
|
113
|
-
#
|
|
114
136
|
# @param filtered [Boolean] Whether the event was filtered and requires improvement.
|
|
115
137
|
#
|
|
116
138
|
# @param improved_model_output [String] Improved model output after improvement tool was applied and each metric passed
|
|
117
139
|
#
|
|
118
140
|
# @param improvement_action [Symbol, Deeprails::Models::WorkflowEventDetailResponse::ImprovementAction] Type of improvement action used to improve the event.
|
|
119
141
|
#
|
|
120
|
-
# @param improvement_tool_status [Symbol, Deeprails::Models::WorkflowEventDetailResponse::ImprovementToolStatus, nil] Status of the improvement tool used to improve the event.
|
|
142
|
+
# @param improvement_tool_status [Symbol, Deeprails::Models::WorkflowEventDetailResponse::ImprovementToolStatus, nil] Status of the improvement tool used to improve the event. `improvement_required`
|
|
143
|
+
#
|
|
144
|
+
# @param key_improvements [Array<Object>]
|
|
145
|
+
#
|
|
146
|
+
# @param status [Symbol, Deeprails::Models::WorkflowEventDetailResponse::Status] Status of the event.
|
|
121
147
|
#
|
|
122
148
|
# @param threshold_type [Symbol, Deeprails::Models::WorkflowEventDetailResponse::ThresholdType] Type of thresholds used to evaluate the event.
|
|
123
149
|
#
|
|
@@ -125,13 +151,20 @@ module Deeprails
|
|
|
125
151
|
#
|
|
126
152
|
# @param automatic_hallucination_tolerance_levels [Hash{Symbol=>Symbol, Deeprails::Models::WorkflowEventDetailResponse::AutomaticHallucinationToleranceLevel}] Mapping of guardrail metric names to tolerance values. Values are strings (`low`
|
|
127
153
|
#
|
|
128
|
-
# @param capabilities [Array<Deeprails::Models::WorkflowEventDetailResponse::Capability>] Extended AI capabilities available to the event, if any. Can be `web_search`
|
|
154
|
+
# @param capabilities [Array<Deeprails::Models::WorkflowEventDetailResponse::Capability>] Extended AI capabilities available to the event, if any. Can be `web_search`, `f
|
|
129
155
|
#
|
|
130
156
|
# @param custom_hallucination_threshold_values [Hash{Symbol=>Float}] Mapping of guardrail metric names to threshold values. Values are floating point
|
|
131
157
|
#
|
|
132
158
|
# @param files [Array<Deeprails::Models::WorkflowEventDetailResponse::File>] List of files available to the event, if any. Will only be present if `file_sear
|
|
159
|
+
#
|
|
160
|
+
# @param max_improvement_attempts [Integer] The maximum number of improvement attempts to be applied to one event before it
|
|
133
161
|
|
|
134
162
|
class EvaluationHistory < Deeprails::Internal::Type::BaseModel
|
|
163
|
+
# @!attribute analysis_of_failures
|
|
164
|
+
#
|
|
165
|
+
# @return [String, nil]
|
|
166
|
+
optional :analysis_of_failures, String
|
|
167
|
+
|
|
135
168
|
# @!attribute attempt
|
|
136
169
|
#
|
|
137
170
|
# @return [String, nil]
|
|
@@ -167,6 +200,17 @@ module Deeprails
|
|
|
167
200
|
# @return [Array<String>, nil]
|
|
168
201
|
optional :guardrail_metrics, Deeprails::Internal::Type::ArrayOf[String]
|
|
169
202
|
|
|
203
|
+
# @!attribute improvement_tool_status
|
|
204
|
+
#
|
|
205
|
+
# @return [Symbol, Deeprails::Models::WorkflowEventDetailResponse::EvaluationHistory::ImprovementToolStatus, nil]
|
|
206
|
+
optional :improvement_tool_status,
|
|
207
|
+
enum: -> { Deeprails::WorkflowEventDetailResponse::EvaluationHistory::ImprovementToolStatus }
|
|
208
|
+
|
|
209
|
+
# @!attribute key_improvements
|
|
210
|
+
#
|
|
211
|
+
# @return [Array<String>, nil]
|
|
212
|
+
optional :key_improvements, Deeprails::Internal::Type::ArrayOf[String]
|
|
213
|
+
|
|
170
214
|
# @!attribute model_input
|
|
171
215
|
#
|
|
172
216
|
# @return [Hash{Symbol=>Object}, nil]
|
|
@@ -177,11 +221,6 @@ module Deeprails
|
|
|
177
221
|
# @return [String, nil]
|
|
178
222
|
optional :model_output, String
|
|
179
223
|
|
|
180
|
-
# @!attribute modified_at
|
|
181
|
-
#
|
|
182
|
-
# @return [Time, nil]
|
|
183
|
-
optional :modified_at, Time
|
|
184
|
-
|
|
185
224
|
# @!attribute nametag
|
|
186
225
|
#
|
|
187
226
|
# @return [String, nil]
|
|
@@ -197,7 +236,8 @@ module Deeprails
|
|
|
197
236
|
# @return [String, nil]
|
|
198
237
|
optional :run_mode, String
|
|
199
238
|
|
|
200
|
-
# @!method initialize(attempt: nil, created_at: nil, error_message: nil, evaluation_result: nil, evaluation_status: nil, evaluation_total_cost: nil, guardrail_metrics: nil,
|
|
239
|
+
# @!method initialize(analysis_of_failures: nil, attempt: nil, created_at: nil, error_message: nil, evaluation_result: nil, evaluation_status: nil, evaluation_total_cost: nil, guardrail_metrics: nil, improvement_tool_status: nil, key_improvements: nil, model_input: nil, model_output: nil, nametag: nil, progress: nil, run_mode: nil)
|
|
240
|
+
# @param analysis_of_failures [String]
|
|
201
241
|
# @param attempt [String]
|
|
202
242
|
# @param created_at [Time]
|
|
203
243
|
# @param error_message [String]
|
|
@@ -205,25 +245,26 @@ module Deeprails
|
|
|
205
245
|
# @param evaluation_status [String]
|
|
206
246
|
# @param evaluation_total_cost [Float]
|
|
207
247
|
# @param guardrail_metrics [Array<String>]
|
|
248
|
+
# @param improvement_tool_status [Symbol, Deeprails::Models::WorkflowEventDetailResponse::EvaluationHistory::ImprovementToolStatus]
|
|
249
|
+
# @param key_improvements [Array<String>]
|
|
208
250
|
# @param model_input [Hash{Symbol=>Object}]
|
|
209
251
|
# @param model_output [String]
|
|
210
|
-
# @param modified_at [Time]
|
|
211
252
|
# @param nametag [String]
|
|
212
253
|
# @param progress [Integer]
|
|
213
254
|
# @param run_mode [String]
|
|
214
|
-
end
|
|
215
255
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
module EventStatus
|
|
220
|
-
extend Deeprails::Internal::Type::Enum
|
|
256
|
+
# @see Deeprails::Models::WorkflowEventDetailResponse::EvaluationHistory#improvement_tool_status
|
|
257
|
+
module ImprovementToolStatus
|
|
258
|
+
extend Deeprails::Internal::Type::Enum
|
|
221
259
|
|
|
222
|
-
|
|
223
|
-
|
|
260
|
+
IMPROVED = :improved
|
|
261
|
+
IMPROVEMENT_FAILED = :improvement_failed
|
|
262
|
+
NO_IMPROVEMENT_REQUIRED = :no_improvement_required
|
|
263
|
+
IMPROVEMENT_REQUIRED = :improvement_required
|
|
224
264
|
|
|
225
|
-
|
|
226
|
-
|
|
265
|
+
# @!method self.values
|
|
266
|
+
# @return [Array<Symbol>]
|
|
267
|
+
end
|
|
227
268
|
end
|
|
228
269
|
|
|
229
270
|
# Type of improvement action used to improve the event.
|
|
@@ -240,20 +281,39 @@ module Deeprails
|
|
|
240
281
|
# @return [Array<Symbol>]
|
|
241
282
|
end
|
|
242
283
|
|
|
243
|
-
# Status of the improvement tool used to improve the event.
|
|
284
|
+
# Status of the improvement tool used to improve the event. `improvement_required`
|
|
285
|
+
# indicates that the evaluation is complete and the improvement action is needed
|
|
286
|
+
# but is not taking place. `improved` and `improvement_failed` indicate when the
|
|
287
|
+
# improvement action concludes, successfully and unsuccessfully, respectively.
|
|
288
|
+
# `no_improvement_required` means that the first evaluation passed all its
|
|
289
|
+
# metrics!
|
|
244
290
|
#
|
|
245
291
|
# @see Deeprails::Models::WorkflowEventDetailResponse#improvement_tool_status
|
|
246
292
|
module ImprovementToolStatus
|
|
247
293
|
extend Deeprails::Internal::Type::Enum
|
|
248
294
|
|
|
249
295
|
IMPROVED = :improved
|
|
250
|
-
|
|
296
|
+
IMPROVEMENT_FAILED = :improvement_failed
|
|
297
|
+
NO_IMPROVEMENT_REQUIRED = :no_improvement_required
|
|
251
298
|
IMPROVEMENT_REQUIRED = :improvement_required
|
|
252
299
|
|
|
253
300
|
# @!method self.values
|
|
254
301
|
# @return [Array<Symbol>]
|
|
255
302
|
end
|
|
256
303
|
|
|
304
|
+
# Status of the event.
|
|
305
|
+
#
|
|
306
|
+
# @see Deeprails::Models::WorkflowEventDetailResponse#status
|
|
307
|
+
module Status
|
|
308
|
+
extend Deeprails::Internal::Type::Enum
|
|
309
|
+
|
|
310
|
+
IN_PROGRESS = :"In Progress"
|
|
311
|
+
COMPLETED = :Completed
|
|
312
|
+
|
|
313
|
+
# @!method self.values
|
|
314
|
+
# @return [Array<Symbol>]
|
|
315
|
+
end
|
|
316
|
+
|
|
257
317
|
# Type of thresholds used to evaluate the event.
|
|
258
318
|
#
|
|
259
319
|
# @see Deeprails::Models::WorkflowEventDetailResponse#threshold_type
|
|
@@ -304,10 +364,22 @@ module Deeprails
|
|
|
304
364
|
# @return [Integer, nil]
|
|
305
365
|
optional :file_size, Integer
|
|
306
366
|
|
|
307
|
-
# @!
|
|
367
|
+
# @!attribute presigned_url
|
|
368
|
+
#
|
|
369
|
+
# @return [String, nil]
|
|
370
|
+
optional :presigned_url, String
|
|
371
|
+
|
|
372
|
+
# @!attribute presigned_url_expires_at
|
|
373
|
+
#
|
|
374
|
+
# @return [Time, nil]
|
|
375
|
+
optional :presigned_url_expires_at, Time
|
|
376
|
+
|
|
377
|
+
# @!method initialize(file_id: nil, file_name: nil, file_size: nil, presigned_url: nil, presigned_url_expires_at: nil)
|
|
308
378
|
# @param file_id [String]
|
|
309
379
|
# @param file_name [String]
|
|
310
380
|
# @param file_size [Integer]
|
|
381
|
+
# @param presigned_url [String]
|
|
382
|
+
# @param presigned_url_expires_at [Time]
|
|
311
383
|
end
|
|
312
384
|
end
|
|
313
385
|
end
|
|
@@ -4,6 +4,12 @@ module Deeprails
|
|
|
4
4
|
module Models
|
|
5
5
|
# @see Deeprails::Resources::Defend#submit_event
|
|
6
6
|
class WorkflowEventResponse < Deeprails::Internal::Type::BaseModel
|
|
7
|
+
# @!attribute billing_request_id
|
|
8
|
+
# The ID of the billing request for the event.
|
|
9
|
+
#
|
|
10
|
+
# @return [String]
|
|
11
|
+
required :billing_request_id, String
|
|
12
|
+
|
|
7
13
|
# @!attribute created_at
|
|
8
14
|
# The time the event was created in UTC.
|
|
9
15
|
#
|
|
@@ -28,7 +34,9 @@ module Deeprails
|
|
|
28
34
|
# @return [String]
|
|
29
35
|
required :workflow_id, String
|
|
30
36
|
|
|
31
|
-
# @!method initialize(created_at:, event_id:, status:, workflow_id:)
|
|
37
|
+
# @!method initialize(billing_request_id:, created_at:, event_id:, status:, workflow_id:)
|
|
38
|
+
# @param billing_request_id [String] The ID of the billing request for the event.
|
|
39
|
+
#
|
|
32
40
|
# @param created_at [Time] The time the event was created in UTC.
|
|
33
41
|
#
|
|
34
42
|
# @param event_id [String] A unique workflow event ID.
|
data/lib/deeprails/models.rb
CHANGED
|
@@ -49,6 +49,8 @@ module Deeprails
|
|
|
49
49
|
|
|
50
50
|
DefendRetrieveWorkflowParams = Deeprails::Models::DefendRetrieveWorkflowParams
|
|
51
51
|
|
|
52
|
+
DefendSubmitAndStreamEventParams = Deeprails::Models::DefendSubmitAndStreamEventParams
|
|
53
|
+
|
|
52
54
|
DefendSubmitEventParams = Deeprails::Models::DefendSubmitEventParams
|
|
53
55
|
|
|
54
56
|
DefendUpdateResponse = Deeprails::Models::DefendUpdateResponse
|
|
@@ -6,10 +6,10 @@ module Deeprails
|
|
|
6
6
|
# Some parameter documentations has been truncated, see
|
|
7
7
|
# {Deeprails::Models::DefendCreateWorkflowParams} for more details.
|
|
8
8
|
#
|
|
9
|
-
# Use this endpoint to create a new guardrail workflow
|
|
10
|
-
# thresholds
|
|
9
|
+
# Use this endpoint to create a new guardrail workflow by specifying guardrail
|
|
10
|
+
# thresholds, an improvement action, and optional extended capabilities.
|
|
11
11
|
#
|
|
12
|
-
# @overload create_workflow(improvement_action:, name:, threshold_type:, automatic_hallucination_tolerance_levels: nil, custom_hallucination_threshold_values: nil, description: nil, file_search: nil, max_improvement_attempts: nil, web_search: nil, request_options: {})
|
|
12
|
+
# @overload create_workflow(improvement_action:, name:, threshold_type:, automatic_hallucination_tolerance_levels: nil, context_awareness: nil, custom_hallucination_threshold_values: nil, description: nil, file_search: nil, max_improvement_attempts: nil, web_search: nil, request_options: {})
|
|
13
13
|
#
|
|
14
14
|
# @param improvement_action [Symbol, Deeprails::Models::DefendCreateWorkflowParams::ImprovementAction] The action used to improve outputs that fail one or more guardrail metrics for t
|
|
15
15
|
#
|
|
@@ -19,6 +19,8 @@ module Deeprails
|
|
|
19
19
|
#
|
|
20
20
|
# @param automatic_hallucination_tolerance_levels [Hash{Symbol=>Symbol, Deeprails::Models::DefendCreateWorkflowParams::AutomaticHallucinationToleranceLevel}] Mapping of guardrail metrics to hallucination tolerance levels
|
|
21
21
|
#
|
|
22
|
+
# @param context_awareness [Boolean] Context includes any structured information that directly relates to the model’s
|
|
23
|
+
#
|
|
22
24
|
# @param custom_hallucination_threshold_values [Hash{Symbol=>Float}] Mapping of guardrail metrics to floating point threshold values. Possible metric
|
|
23
25
|
#
|
|
24
26
|
# @param description [String] Description for the workflow.
|
|
@@ -99,6 +101,48 @@ module Deeprails
|
|
|
99
101
|
)
|
|
100
102
|
end
|
|
101
103
|
|
|
104
|
+
# Some parameter documentations has been truncated, see
|
|
105
|
+
# {Deeprails::Models::DefendSubmitAndStreamEventParams} for more details.
|
|
106
|
+
#
|
|
107
|
+
# Use this endpoint to create a new event for a guardrail workflow with real-time
|
|
108
|
+
# streaming feedback via Server-Sent Events (SSE).
|
|
109
|
+
#
|
|
110
|
+
# @overload submit_and_stream_event_streaming(workflow_id, model_input:, model_output:, model_used:, run_mode:, stream: nil, nametag: nil, request_options: {})
|
|
111
|
+
#
|
|
112
|
+
# @param workflow_id [String] Path param: The ID of the workflow to create the event for.
|
|
113
|
+
#
|
|
114
|
+
# @param model_input [Hash{Symbol=>Object}] Body param: The input provided to the model (e.g., prompt, messages).
|
|
115
|
+
#
|
|
116
|
+
# @param model_output [String] Body param: The output generated by the model to be evaluated.
|
|
117
|
+
#
|
|
118
|
+
# @param model_used [String] Body param: The model that generated the output (e.g., "gpt-4", "claude-3").
|
|
119
|
+
#
|
|
120
|
+
# @param run_mode [Symbol, Deeprails::Models::DefendSubmitAndStreamEventParams::RunMode] Body param: The evaluation run mode. Streaming only supports fast, precision, an
|
|
121
|
+
#
|
|
122
|
+
# @param stream [Boolean] Query param: Enable SSE streaming for real-time token feedback. Only supported f
|
|
123
|
+
#
|
|
124
|
+
# @param nametag [String] Body param: Optional tag to identify this event.
|
|
125
|
+
#
|
|
126
|
+
# @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
127
|
+
#
|
|
128
|
+
# @return [Deeprails::Internal::Stream<String>]
|
|
129
|
+
#
|
|
130
|
+
# @see Deeprails::Models::DefendSubmitAndStreamEventParams
|
|
131
|
+
def submit_and_stream_event_streaming(workflow_id, params)
|
|
132
|
+
parsed, options = Deeprails::DefendSubmitAndStreamEventParams.dump_request(params)
|
|
133
|
+
query_params = [:stream]
|
|
134
|
+
@client.request(
|
|
135
|
+
method: :post,
|
|
136
|
+
path: ["defend/%1$s/events?stream=true", workflow_id],
|
|
137
|
+
query: parsed.slice(*query_params),
|
|
138
|
+
headers: {"accept" => "text/event-stream"},
|
|
139
|
+
body: parsed.except(*query_params),
|
|
140
|
+
stream: Deeprails::Internal::Stream,
|
|
141
|
+
model: String,
|
|
142
|
+
options: options
|
|
143
|
+
)
|
|
144
|
+
end
|
|
145
|
+
|
|
102
146
|
# Some parameter documentations has been truncated, see
|
|
103
147
|
# {Deeprails::Models::DefendSubmitEventParams} for more details.
|
|
104
148
|
#
|
|
@@ -135,15 +179,34 @@ module Deeprails
|
|
|
135
179
|
)
|
|
136
180
|
end
|
|
137
181
|
|
|
138
|
-
#
|
|
182
|
+
# Some parameter documentations has been truncated, see
|
|
183
|
+
# {Deeprails::Models::DefendUpdateWorkflowParams} for more details.
|
|
184
|
+
#
|
|
185
|
+
# Use this endpoint to update an existing defend workflow if its details change.
|
|
139
186
|
#
|
|
140
|
-
# @overload update_workflow(workflow_id, description: nil, name: nil, request_options: {})
|
|
187
|
+
# @overload update_workflow(workflow_id, automatic_hallucination_tolerance_levels: nil, context_awareness: nil, custom_hallucination_threshold_values: nil, description: nil, file_search: nil, improvement_action: nil, max_improvement_attempts: nil, name: nil, threshold_type: nil, web_search: nil, request_options: {})
|
|
141
188
|
#
|
|
142
189
|
# @param workflow_id [String] The ID of the workflow to edit.
|
|
143
190
|
#
|
|
144
|
-
# @param
|
|
191
|
+
# @param automatic_hallucination_tolerance_levels [Hash{Symbol=>Symbol, Deeprails::Models::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel}] New mapping of guardrail metrics to hallucination tolerance levels
|
|
145
192
|
#
|
|
146
|
-
# @param
|
|
193
|
+
# @param context_awareness [Boolean] Whether to enable context awareness for this workflow's evaluations.
|
|
194
|
+
#
|
|
195
|
+
# @param custom_hallucination_threshold_values [Hash{Symbol=>Float}] New mapping of guardrail metrics to floating point threshold values to be used w
|
|
196
|
+
#
|
|
197
|
+
# @param description [String] New description for the workflow.
|
|
198
|
+
#
|
|
199
|
+
# @param file_search [Array<String>] An array of file IDs to search in the workflow's evaluations. Files must be uplo
|
|
200
|
+
#
|
|
201
|
+
# @param improvement_action [Symbol, Deeprails::Models::DefendUpdateWorkflowParams::ImprovementAction] The new action used to improve outputs that fail one or more guardrail metrics f
|
|
202
|
+
#
|
|
203
|
+
# @param max_improvement_attempts [Integer] Max. number of improvement action attempts until a given event passes the guardr
|
|
204
|
+
#
|
|
205
|
+
# @param name [String] New name for the workflow.
|
|
206
|
+
#
|
|
207
|
+
# @param threshold_type [Symbol, Deeprails::Models::DefendUpdateWorkflowParams::ThresholdType] New type of thresholds to use for the workflow, either `automatic` or `custom`.
|
|
208
|
+
#
|
|
209
|
+
# @param web_search [Boolean] Whether to enable web search for this workflow's evaluations.
|
|
147
210
|
#
|
|
148
211
|
# @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
149
212
|
#
|
|
@@ -5,9 +5,9 @@ module Deeprails
|
|
|
5
5
|
class Files
|
|
6
6
|
# Use this endpoint to upload a file to the DeepRails API
|
|
7
7
|
#
|
|
8
|
-
# @overload upload(
|
|
8
|
+
# @overload upload(files:, request_options: {})
|
|
9
9
|
#
|
|
10
|
-
# @param
|
|
10
|
+
# @param files [Array<String>] The contents of the files to upload.
|
|
11
11
|
#
|
|
12
12
|
# @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
13
13
|
#
|
|
@@ -9,12 +9,14 @@ module Deeprails
|
|
|
9
9
|
# Use this endpoint to create a new monitor to evaluate model inputs and outputs
|
|
10
10
|
# using guardrails
|
|
11
11
|
#
|
|
12
|
-
# @overload create(guardrail_metrics:, name:, description: nil, file_search: nil, web_search: nil, request_options: {})
|
|
12
|
+
# @overload create(guardrail_metrics:, name:, context_awareness: nil, description: nil, file_search: nil, web_search: nil, request_options: {})
|
|
13
13
|
#
|
|
14
14
|
# @param guardrail_metrics [Array<Symbol, Deeprails::Models::MonitorCreateParams::GuardrailMetric>] An array of guardrail metrics that the model input and output pair will be evalu
|
|
15
15
|
#
|
|
16
16
|
# @param name [String] Name of the new monitor.
|
|
17
17
|
#
|
|
18
|
+
# @param context_awareness [Boolean] Context includes any structured information that directly relates to the model’s
|
|
19
|
+
#
|
|
18
20
|
# @param description [String] Description of the new monitor.
|
|
19
21
|
#
|
|
20
22
|
# @param file_search [Array<String>] An array of file IDs to search in the monitor's evaluations. Files must be uploa
|
|
@@ -68,19 +70,25 @@ module Deeprails
|
|
|
68
70
|
# Some parameter documentations has been truncated, see
|
|
69
71
|
# {Deeprails::Models::MonitorUpdateParams} for more details.
|
|
70
72
|
#
|
|
71
|
-
# Use this endpoint to update the name,
|
|
72
|
-
# monitor
|
|
73
|
+
# Use this endpoint to update the name, status, and/or other details of an
|
|
74
|
+
# existing monitor.
|
|
73
75
|
#
|
|
74
|
-
# @overload update(monitor_id, description: nil, name: nil, status: nil, request_options: {})
|
|
76
|
+
# @overload update(monitor_id, description: nil, file_search: nil, guardrail_metrics: nil, name: nil, status: nil, web_search: nil, request_options: {})
|
|
75
77
|
#
|
|
76
78
|
# @param monitor_id [String] The ID of the monitor to edit.
|
|
77
79
|
#
|
|
78
|
-
# @param description [String]
|
|
80
|
+
# @param description [String] New description of the monitor.
|
|
81
|
+
#
|
|
82
|
+
# @param file_search [Array<String>] An array of file IDs to search in the monitor's evaluations. Files must be uploa
|
|
79
83
|
#
|
|
80
|
-
# @param
|
|
84
|
+
# @param guardrail_metrics [Array<Symbol, Deeprails::Models::MonitorUpdateParams::GuardrailMetric>] An array of the new guardrail metrics that model input and output pairs will be
|
|
85
|
+
#
|
|
86
|
+
# @param name [String] New name of the monitor.
|
|
81
87
|
#
|
|
82
88
|
# @param status [Symbol, Deeprails::Models::MonitorUpdateParams::Status] Status of the monitor. Can be `active` or `inactive`. Inactive monitors no lon
|
|
83
89
|
#
|
|
90
|
+
# @param web_search [Boolean] Whether to enable web search for this monitor's evaluations.
|
|
91
|
+
#
|
|
84
92
|
# @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
85
93
|
#
|
|
86
94
|
# @return [Deeprails::Models::MonitorUpdateResponse]
|
data/lib/deeprails/version.rb
CHANGED
data/lib/deeprails.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# Standard libraries.
|
|
4
4
|
# rubocop:disable Lint/RedundantRequireStatement
|
|
5
5
|
require "English"
|
|
6
|
+
require "base64"
|
|
6
7
|
require "cgi"
|
|
7
8
|
require "date"
|
|
8
9
|
require "erb"
|
|
@@ -43,6 +44,7 @@ require_relative "deeprails/internal/type/array_of"
|
|
|
43
44
|
require_relative "deeprails/internal/type/hash_of"
|
|
44
45
|
require_relative "deeprails/internal/type/base_model"
|
|
45
46
|
require_relative "deeprails/internal/type/base_page"
|
|
47
|
+
require_relative "deeprails/internal/type/base_stream"
|
|
46
48
|
require_relative "deeprails/internal/type/request_parameters"
|
|
47
49
|
require_relative "deeprails/internal"
|
|
48
50
|
require_relative "deeprails/request_options"
|
|
@@ -51,11 +53,14 @@ require_relative "deeprails/errors"
|
|
|
51
53
|
require_relative "deeprails/internal/transport/base_client"
|
|
52
54
|
require_relative "deeprails/internal/transport/pooled_net_requester"
|
|
53
55
|
require_relative "deeprails/client"
|
|
56
|
+
require_relative "deeprails/internal/stream"
|
|
54
57
|
require_relative "deeprails/models/defend_create_response"
|
|
55
58
|
require_relative "deeprails/models/defend_create_workflow_params"
|
|
56
59
|
require_relative "deeprails/models/defend_response"
|
|
57
60
|
require_relative "deeprails/models/defend_retrieve_event_params"
|
|
58
61
|
require_relative "deeprails/models/defend_retrieve_workflow_params"
|
|
62
|
+
require_relative "deeprails/models/defend_submit_and_stream_event_params"
|
|
63
|
+
require_relative "deeprails/models/defend_submit_and_stream_event_response"
|
|
59
64
|
require_relative "deeprails/models/defend_submit_event_params"
|
|
60
65
|
require_relative "deeprails/models/defend_update_response"
|
|
61
66
|
require_relative "deeprails/models/defend_update_workflow_params"
|
data/manifest.yaml
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Deeprails
|
|
4
|
+
module Internal
|
|
5
|
+
class Stream
|
|
6
|
+
Message =
|
|
7
|
+
type_member(:in) do
|
|
8
|
+
{ fixed: Deeprails::Internal::Util::ServerSentEvent }
|
|
9
|
+
end
|
|
10
|
+
Elem = type_member(:out)
|
|
11
|
+
|
|
12
|
+
include Deeprails::Internal::Type::BaseStream
|
|
13
|
+
|
|
14
|
+
# @api private
|
|
15
|
+
sig { override.returns(T::Enumerable[Elem]) }
|
|
16
|
+
private def iterator
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -49,7 +49,15 @@ module Deeprails
|
|
|
49
49
|
]
|
|
50
50
|
]
|
|
51
51
|
),
|
|
52
|
-
stream:
|
|
52
|
+
stream:
|
|
53
|
+
T.nilable(
|
|
54
|
+
T::Class[
|
|
55
|
+
Deeprails::Internal::Type::BaseStream[
|
|
56
|
+
T.anything,
|
|
57
|
+
Deeprails::Internal::Type::BaseModel
|
|
58
|
+
]
|
|
59
|
+
]
|
|
60
|
+
),
|
|
53
61
|
model: T.nilable(Deeprails::Internal::Type::Converter::Input),
|
|
54
62
|
options: T.nilable(Deeprails::RequestOptions::OrHash)
|
|
55
63
|
}
|
|
@@ -269,7 +277,15 @@ module Deeprails
|
|
|
269
277
|
]
|
|
270
278
|
]
|
|
271
279
|
),
|
|
272
|
-
stream:
|
|
280
|
+
stream:
|
|
281
|
+
T.nilable(
|
|
282
|
+
T::Class[
|
|
283
|
+
Deeprails::Internal::Type::BaseStream[
|
|
284
|
+
T.anything,
|
|
285
|
+
Deeprails::Internal::Type::BaseModel
|
|
286
|
+
]
|
|
287
|
+
]
|
|
288
|
+
),
|
|
273
289
|
model: T.nilable(Deeprails::Internal::Type::Converter::Input),
|
|
274
290
|
options: T.nilable(Deeprails::RequestOptions::OrHash)
|
|
275
291
|
).returns(T.anything)
|