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
|
@@ -14,32 +14,193 @@ module Deeprails
|
|
|
14
14
|
)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
#
|
|
17
|
+
# New mapping of guardrail metrics to hallucination tolerance levels (either
|
|
18
|
+
# `low`, `medium`, or `high`) to be used when `threshold_type` is set to
|
|
19
|
+
# `automatic`. Possible metrics are `completeness`, `instruction_adherence`,
|
|
20
|
+
# `context_adherence`, `ground_truth_adherence`, or `comprehensive_safety`.
|
|
21
|
+
sig do
|
|
22
|
+
returns(
|
|
23
|
+
T.nilable(
|
|
24
|
+
T::Hash[
|
|
25
|
+
Symbol,
|
|
26
|
+
Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::OrSymbol
|
|
27
|
+
]
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
attr_reader :automatic_hallucination_tolerance_levels
|
|
32
|
+
|
|
33
|
+
sig do
|
|
34
|
+
params(
|
|
35
|
+
automatic_hallucination_tolerance_levels:
|
|
36
|
+
T::Hash[
|
|
37
|
+
Symbol,
|
|
38
|
+
Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::OrSymbol
|
|
39
|
+
]
|
|
40
|
+
).void
|
|
41
|
+
end
|
|
42
|
+
attr_writer :automatic_hallucination_tolerance_levels
|
|
43
|
+
|
|
44
|
+
# Whether to enable context awareness for this workflow's evaluations.
|
|
45
|
+
sig { returns(T.nilable(T::Boolean)) }
|
|
46
|
+
attr_reader :context_awareness
|
|
47
|
+
|
|
48
|
+
sig { params(context_awareness: T::Boolean).void }
|
|
49
|
+
attr_writer :context_awareness
|
|
50
|
+
|
|
51
|
+
# New mapping of guardrail metrics to floating point threshold values to be used
|
|
52
|
+
# when `threshold_type` is set to `custom`. Possible metrics are `correctness`,
|
|
53
|
+
# `completeness`, `instruction_adherence`, `context_adherence`,
|
|
54
|
+
# `ground_truth_adherence`, or `comprehensive_safety`.
|
|
55
|
+
sig { returns(T.nilable(T::Hash[Symbol, Float])) }
|
|
56
|
+
attr_reader :custom_hallucination_threshold_values
|
|
57
|
+
|
|
58
|
+
sig do
|
|
59
|
+
params(
|
|
60
|
+
custom_hallucination_threshold_values: T::Hash[Symbol, Float]
|
|
61
|
+
).void
|
|
62
|
+
end
|
|
63
|
+
attr_writer :custom_hallucination_threshold_values
|
|
64
|
+
|
|
65
|
+
# New description for the workflow.
|
|
18
66
|
sig { returns(T.nilable(String)) }
|
|
19
67
|
attr_reader :description
|
|
20
68
|
|
|
21
69
|
sig { params(description: String).void }
|
|
22
70
|
attr_writer :description
|
|
23
71
|
|
|
24
|
-
#
|
|
72
|
+
# An array of file IDs to search in the workflow's evaluations. Files must be
|
|
73
|
+
# uploaded via the DeepRails API first.
|
|
74
|
+
sig { returns(T.nilable(T::Array[String])) }
|
|
75
|
+
attr_reader :file_search
|
|
76
|
+
|
|
77
|
+
sig { params(file_search: T::Array[String]).void }
|
|
78
|
+
attr_writer :file_search
|
|
79
|
+
|
|
80
|
+
# The new action used to improve outputs that fail one or more guardrail metrics
|
|
81
|
+
# for the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs
|
|
82
|
+
# the user's input prompt with minor induced variance. FixIt attempts to directly
|
|
83
|
+
# address the shortcomings of the output using the guardrail failure rationale. Do
|
|
84
|
+
# Nothing does not attempt any improvement.
|
|
85
|
+
sig do
|
|
86
|
+
returns(
|
|
87
|
+
T.nilable(
|
|
88
|
+
Deeprails::DefendUpdateWorkflowParams::ImprovementAction::OrSymbol
|
|
89
|
+
)
|
|
90
|
+
)
|
|
91
|
+
end
|
|
92
|
+
attr_reader :improvement_action
|
|
93
|
+
|
|
94
|
+
sig do
|
|
95
|
+
params(
|
|
96
|
+
improvement_action:
|
|
97
|
+
Deeprails::DefendUpdateWorkflowParams::ImprovementAction::OrSymbol
|
|
98
|
+
).void
|
|
99
|
+
end
|
|
100
|
+
attr_writer :improvement_action
|
|
101
|
+
|
|
102
|
+
# Max. number of improvement action attempts until a given event passes the
|
|
103
|
+
# guardrails. Defaults to 10.
|
|
104
|
+
sig { returns(T.nilable(Integer)) }
|
|
105
|
+
attr_reader :max_improvement_attempts
|
|
106
|
+
|
|
107
|
+
sig { params(max_improvement_attempts: Integer).void }
|
|
108
|
+
attr_writer :max_improvement_attempts
|
|
109
|
+
|
|
110
|
+
# New name for the workflow.
|
|
25
111
|
sig { returns(T.nilable(String)) }
|
|
26
112
|
attr_reader :name
|
|
27
113
|
|
|
28
114
|
sig { params(name: String).void }
|
|
29
115
|
attr_writer :name
|
|
30
116
|
|
|
117
|
+
# New type of thresholds to use for the workflow, either `automatic` or `custom`.
|
|
118
|
+
# Automatic thresholds are assigned internally after the user specifies a
|
|
119
|
+
# qualitative tolerance for the metrics, whereas custom metrics allow the user to
|
|
120
|
+
# set the threshold for each metric as a floating point number between 0.0 and
|
|
121
|
+
# 1.0.
|
|
122
|
+
sig do
|
|
123
|
+
returns(
|
|
124
|
+
T.nilable(
|
|
125
|
+
Deeprails::DefendUpdateWorkflowParams::ThresholdType::OrSymbol
|
|
126
|
+
)
|
|
127
|
+
)
|
|
128
|
+
end
|
|
129
|
+
attr_reader :threshold_type
|
|
130
|
+
|
|
131
|
+
sig do
|
|
132
|
+
params(
|
|
133
|
+
threshold_type:
|
|
134
|
+
Deeprails::DefendUpdateWorkflowParams::ThresholdType::OrSymbol
|
|
135
|
+
).void
|
|
136
|
+
end
|
|
137
|
+
attr_writer :threshold_type
|
|
138
|
+
|
|
139
|
+
# Whether to enable web search for this workflow's evaluations.
|
|
140
|
+
sig { returns(T.nilable(T::Boolean)) }
|
|
141
|
+
attr_reader :web_search
|
|
142
|
+
|
|
143
|
+
sig { params(web_search: T::Boolean).void }
|
|
144
|
+
attr_writer :web_search
|
|
145
|
+
|
|
31
146
|
sig do
|
|
32
147
|
params(
|
|
148
|
+
automatic_hallucination_tolerance_levels:
|
|
149
|
+
T::Hash[
|
|
150
|
+
Symbol,
|
|
151
|
+
Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::OrSymbol
|
|
152
|
+
],
|
|
153
|
+
context_awareness: T::Boolean,
|
|
154
|
+
custom_hallucination_threshold_values: T::Hash[Symbol, Float],
|
|
33
155
|
description: String,
|
|
156
|
+
file_search: T::Array[String],
|
|
157
|
+
improvement_action:
|
|
158
|
+
Deeprails::DefendUpdateWorkflowParams::ImprovementAction::OrSymbol,
|
|
159
|
+
max_improvement_attempts: Integer,
|
|
34
160
|
name: String,
|
|
161
|
+
threshold_type:
|
|
162
|
+
Deeprails::DefendUpdateWorkflowParams::ThresholdType::OrSymbol,
|
|
163
|
+
web_search: T::Boolean,
|
|
35
164
|
request_options: Deeprails::RequestOptions::OrHash
|
|
36
165
|
).returns(T.attached_class)
|
|
37
166
|
end
|
|
38
167
|
def self.new(
|
|
39
|
-
#
|
|
168
|
+
# New mapping of guardrail metrics to hallucination tolerance levels (either
|
|
169
|
+
# `low`, `medium`, or `high`) to be used when `threshold_type` is set to
|
|
170
|
+
# `automatic`. Possible metrics are `completeness`, `instruction_adherence`,
|
|
171
|
+
# `context_adherence`, `ground_truth_adherence`, or `comprehensive_safety`.
|
|
172
|
+
automatic_hallucination_tolerance_levels: nil,
|
|
173
|
+
# Whether to enable context awareness for this workflow's evaluations.
|
|
174
|
+
context_awareness: nil,
|
|
175
|
+
# New mapping of guardrail metrics to floating point threshold values to be used
|
|
176
|
+
# when `threshold_type` is set to `custom`. Possible metrics are `correctness`,
|
|
177
|
+
# `completeness`, `instruction_adherence`, `context_adherence`,
|
|
178
|
+
# `ground_truth_adherence`, or `comprehensive_safety`.
|
|
179
|
+
custom_hallucination_threshold_values: nil,
|
|
180
|
+
# New description for the workflow.
|
|
40
181
|
description: nil,
|
|
41
|
-
#
|
|
182
|
+
# An array of file IDs to search in the workflow's evaluations. Files must be
|
|
183
|
+
# uploaded via the DeepRails API first.
|
|
184
|
+
file_search: nil,
|
|
185
|
+
# The new action used to improve outputs that fail one or more guardrail metrics
|
|
186
|
+
# for the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs
|
|
187
|
+
# the user's input prompt with minor induced variance. FixIt attempts to directly
|
|
188
|
+
# address the shortcomings of the output using the guardrail failure rationale. Do
|
|
189
|
+
# Nothing does not attempt any improvement.
|
|
190
|
+
improvement_action: nil,
|
|
191
|
+
# Max. number of improvement action attempts until a given event passes the
|
|
192
|
+
# guardrails. Defaults to 10.
|
|
193
|
+
max_improvement_attempts: nil,
|
|
194
|
+
# New name for the workflow.
|
|
42
195
|
name: nil,
|
|
196
|
+
# New type of thresholds to use for the workflow, either `automatic` or `custom`.
|
|
197
|
+
# Automatic thresholds are assigned internally after the user specifies a
|
|
198
|
+
# qualitative tolerance for the metrics, whereas custom metrics allow the user to
|
|
199
|
+
# set the threshold for each metric as a floating point number between 0.0 and
|
|
200
|
+
# 1.0.
|
|
201
|
+
threshold_type: nil,
|
|
202
|
+
# Whether to enable web search for this workflow's evaluations.
|
|
203
|
+
web_search: nil,
|
|
43
204
|
request_options: {}
|
|
44
205
|
)
|
|
45
206
|
end
|
|
@@ -47,14 +208,147 @@ module Deeprails
|
|
|
47
208
|
sig do
|
|
48
209
|
override.returns(
|
|
49
210
|
{
|
|
211
|
+
automatic_hallucination_tolerance_levels:
|
|
212
|
+
T::Hash[
|
|
213
|
+
Symbol,
|
|
214
|
+
Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::OrSymbol
|
|
215
|
+
],
|
|
216
|
+
context_awareness: T::Boolean,
|
|
217
|
+
custom_hallucination_threshold_values: T::Hash[Symbol, Float],
|
|
50
218
|
description: String,
|
|
219
|
+
file_search: T::Array[String],
|
|
220
|
+
improvement_action:
|
|
221
|
+
Deeprails::DefendUpdateWorkflowParams::ImprovementAction::OrSymbol,
|
|
222
|
+
max_improvement_attempts: Integer,
|
|
51
223
|
name: String,
|
|
224
|
+
threshold_type:
|
|
225
|
+
Deeprails::DefendUpdateWorkflowParams::ThresholdType::OrSymbol,
|
|
226
|
+
web_search: T::Boolean,
|
|
52
227
|
request_options: Deeprails::RequestOptions
|
|
53
228
|
}
|
|
54
229
|
)
|
|
55
230
|
end
|
|
56
231
|
def to_hash
|
|
57
232
|
end
|
|
233
|
+
|
|
234
|
+
module AutomaticHallucinationToleranceLevel
|
|
235
|
+
extend Deeprails::Internal::Type::Enum
|
|
236
|
+
|
|
237
|
+
TaggedSymbol =
|
|
238
|
+
T.type_alias do
|
|
239
|
+
T.all(
|
|
240
|
+
Symbol,
|
|
241
|
+
Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel
|
|
242
|
+
)
|
|
243
|
+
end
|
|
244
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
245
|
+
|
|
246
|
+
LOW =
|
|
247
|
+
T.let(
|
|
248
|
+
:low,
|
|
249
|
+
Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::TaggedSymbol
|
|
250
|
+
)
|
|
251
|
+
MEDIUM =
|
|
252
|
+
T.let(
|
|
253
|
+
:medium,
|
|
254
|
+
Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::TaggedSymbol
|
|
255
|
+
)
|
|
256
|
+
HIGH =
|
|
257
|
+
T.let(
|
|
258
|
+
:high,
|
|
259
|
+
Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::TaggedSymbol
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
sig do
|
|
263
|
+
override.returns(
|
|
264
|
+
T::Array[
|
|
265
|
+
Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::TaggedSymbol
|
|
266
|
+
]
|
|
267
|
+
)
|
|
268
|
+
end
|
|
269
|
+
def self.values
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
# The new action used to improve outputs that fail one or more guardrail metrics
|
|
274
|
+
# for the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs
|
|
275
|
+
# the user's input prompt with minor induced variance. FixIt attempts to directly
|
|
276
|
+
# address the shortcomings of the output using the guardrail failure rationale. Do
|
|
277
|
+
# Nothing does not attempt any improvement.
|
|
278
|
+
module ImprovementAction
|
|
279
|
+
extend Deeprails::Internal::Type::Enum
|
|
280
|
+
|
|
281
|
+
TaggedSymbol =
|
|
282
|
+
T.type_alias do
|
|
283
|
+
T.all(
|
|
284
|
+
Symbol,
|
|
285
|
+
Deeprails::DefendUpdateWorkflowParams::ImprovementAction
|
|
286
|
+
)
|
|
287
|
+
end
|
|
288
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
289
|
+
|
|
290
|
+
REGEN =
|
|
291
|
+
T.let(
|
|
292
|
+
:regen,
|
|
293
|
+
Deeprails::DefendUpdateWorkflowParams::ImprovementAction::TaggedSymbol
|
|
294
|
+
)
|
|
295
|
+
FIXIT =
|
|
296
|
+
T.let(
|
|
297
|
+
:fixit,
|
|
298
|
+
Deeprails::DefendUpdateWorkflowParams::ImprovementAction::TaggedSymbol
|
|
299
|
+
)
|
|
300
|
+
DO_NOTHING =
|
|
301
|
+
T.let(
|
|
302
|
+
:do_nothing,
|
|
303
|
+
Deeprails::DefendUpdateWorkflowParams::ImprovementAction::TaggedSymbol
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
sig do
|
|
307
|
+
override.returns(
|
|
308
|
+
T::Array[
|
|
309
|
+
Deeprails::DefendUpdateWorkflowParams::ImprovementAction::TaggedSymbol
|
|
310
|
+
]
|
|
311
|
+
)
|
|
312
|
+
end
|
|
313
|
+
def self.values
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
# New type of thresholds to use for the workflow, either `automatic` or `custom`.
|
|
318
|
+
# Automatic thresholds are assigned internally after the user specifies a
|
|
319
|
+
# qualitative tolerance for the metrics, whereas custom metrics allow the user to
|
|
320
|
+
# set the threshold for each metric as a floating point number between 0.0 and
|
|
321
|
+
# 1.0.
|
|
322
|
+
module ThresholdType
|
|
323
|
+
extend Deeprails::Internal::Type::Enum
|
|
324
|
+
|
|
325
|
+
TaggedSymbol =
|
|
326
|
+
T.type_alias do
|
|
327
|
+
T.all(Symbol, Deeprails::DefendUpdateWorkflowParams::ThresholdType)
|
|
328
|
+
end
|
|
329
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
330
|
+
|
|
331
|
+
AUTOMATIC =
|
|
332
|
+
T.let(
|
|
333
|
+
:automatic,
|
|
334
|
+
Deeprails::DefendUpdateWorkflowParams::ThresholdType::TaggedSymbol
|
|
335
|
+
)
|
|
336
|
+
CUSTOM =
|
|
337
|
+
T.let(
|
|
338
|
+
:custom,
|
|
339
|
+
Deeprails::DefendUpdateWorkflowParams::ThresholdType::TaggedSymbol
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
sig do
|
|
343
|
+
override.returns(
|
|
344
|
+
T::Array[
|
|
345
|
+
Deeprails::DefendUpdateWorkflowParams::ThresholdType::TaggedSymbol
|
|
346
|
+
]
|
|
347
|
+
)
|
|
348
|
+
end
|
|
349
|
+
def self.values
|
|
350
|
+
end
|
|
351
|
+
end
|
|
58
352
|
end
|
|
59
353
|
end
|
|
60
354
|
end
|
|
@@ -11,26 +11,29 @@ module Deeprails
|
|
|
11
11
|
T.any(Deeprails::FileUploadParams, Deeprails::Internal::AnyHash)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
# The contents of the
|
|
14
|
+
# The contents of the files to upload.
|
|
15
15
|
sig { returns(T::Array[String]) }
|
|
16
|
-
attr_accessor :
|
|
16
|
+
attr_accessor :files
|
|
17
17
|
|
|
18
18
|
sig do
|
|
19
19
|
params(
|
|
20
|
-
|
|
20
|
+
files: T::Array[String],
|
|
21
21
|
request_options: Deeprails::RequestOptions::OrHash
|
|
22
22
|
).returns(T.attached_class)
|
|
23
23
|
end
|
|
24
24
|
def self.new(
|
|
25
|
-
# The contents of the
|
|
26
|
-
|
|
25
|
+
# The contents of the files to upload.
|
|
26
|
+
files:,
|
|
27
27
|
request_options: {}
|
|
28
28
|
)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
sig do
|
|
32
32
|
override.returns(
|
|
33
|
-
{
|
|
33
|
+
{
|
|
34
|
+
files: T::Array[String],
|
|
35
|
+
request_options: Deeprails::RequestOptions
|
|
36
|
+
}
|
|
34
37
|
)
|
|
35
38
|
end
|
|
36
39
|
def to_hash
|
|
@@ -26,6 +26,18 @@ module Deeprails
|
|
|
26
26
|
sig { returns(String) }
|
|
27
27
|
attr_accessor :name
|
|
28
28
|
|
|
29
|
+
# Context includes any structured information that directly relates to the model’s
|
|
30
|
+
# input and expected output—e.g., the recent turn-by-turn history between an AI
|
|
31
|
+
# tutor and a student, facts or state passed through an agentic workflow, or other
|
|
32
|
+
# domain-specific signals your system already knows and wants the model to
|
|
33
|
+
# condition on. This field determines whether to enable context awareness for this
|
|
34
|
+
# monitor's evaluations. Defaults to false.
|
|
35
|
+
sig { returns(T.nilable(T::Boolean)) }
|
|
36
|
+
attr_reader :context_awareness
|
|
37
|
+
|
|
38
|
+
sig { params(context_awareness: T::Boolean).void }
|
|
39
|
+
attr_writer :context_awareness
|
|
40
|
+
|
|
29
41
|
# Description of the new monitor.
|
|
30
42
|
sig { returns(T.nilable(String)) }
|
|
31
43
|
attr_reader :description
|
|
@@ -53,6 +65,7 @@ module Deeprails
|
|
|
53
65
|
guardrail_metrics:
|
|
54
66
|
T::Array[Deeprails::MonitorCreateParams::GuardrailMetric::OrSymbol],
|
|
55
67
|
name: String,
|
|
68
|
+
context_awareness: T::Boolean,
|
|
56
69
|
description: String,
|
|
57
70
|
file_search: T::Array[String],
|
|
58
71
|
web_search: T::Boolean,
|
|
@@ -67,6 +80,13 @@ module Deeprails
|
|
|
67
80
|
guardrail_metrics:,
|
|
68
81
|
# Name of the new monitor.
|
|
69
82
|
name:,
|
|
83
|
+
# Context includes any structured information that directly relates to the model’s
|
|
84
|
+
# input and expected output—e.g., the recent turn-by-turn history between an AI
|
|
85
|
+
# tutor and a student, facts or state passed through an agentic workflow, or other
|
|
86
|
+
# domain-specific signals your system already knows and wants the model to
|
|
87
|
+
# condition on. This field determines whether to enable context awareness for this
|
|
88
|
+
# monitor's evaluations. Defaults to false.
|
|
89
|
+
context_awareness: nil,
|
|
70
90
|
# Description of the new monitor.
|
|
71
91
|
description: nil,
|
|
72
92
|
# An array of file IDs to search in the monitor's evaluations. Files must be
|
|
@@ -86,6 +106,7 @@ module Deeprails
|
|
|
86
106
|
Deeprails::MonitorCreateParams::GuardrailMetric::OrSymbol
|
|
87
107
|
],
|
|
88
108
|
name: String,
|
|
109
|
+
context_awareness: T::Boolean,
|
|
89
110
|
description: String,
|
|
90
111
|
file_search: T::Array[String],
|
|
91
112
|
web_search: T::Boolean,
|
|
@@ -8,7 +8,8 @@ module Deeprails
|
|
|
8
8
|
T.any(Deeprails::MonitorDetailResponse, Deeprails::Internal::AnyHash)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
# An array of capabilities associated with this monitor.
|
|
11
|
+
# An array of extended AI capabilities associated with this monitor. Can be
|
|
12
|
+
# `web_search`, `file_search`, and/or `context_awareness`.
|
|
12
13
|
sig { returns(T::Array[Deeprails::MonitorDetailResponse::Capability]) }
|
|
13
14
|
attr_accessor :capabilities
|
|
14
15
|
|
|
@@ -77,7 +78,8 @@ module Deeprails
|
|
|
77
78
|
).returns(T.attached_class)
|
|
78
79
|
end
|
|
79
80
|
def self.new(
|
|
80
|
-
# An array of capabilities associated with this monitor.
|
|
81
|
+
# An array of extended AI capabilities associated with this monitor. Can be
|
|
82
|
+
# `web_search`, `file_search`, and/or `context_awareness`.
|
|
81
83
|
capabilities:,
|
|
82
84
|
# The time the monitor was created in UTC.
|
|
83
85
|
created_at:,
|
|
@@ -170,8 +172,9 @@ module Deeprails
|
|
|
170
172
|
attr_accessor :evaluation_status
|
|
171
173
|
|
|
172
174
|
# A dictionary of inputs sent to the LLM to generate output. The dictionary must
|
|
173
|
-
# contain
|
|
174
|
-
#
|
|
175
|
+
# contain a `user_prompt` field. For ground_truth_adherence guardrail metric,
|
|
176
|
+
# `ground_truth` should be provided. When `context_awareness` is enabled,
|
|
177
|
+
# `context` should be provided.
|
|
175
178
|
sig do
|
|
176
179
|
returns(Deeprails::MonitorDetailResponse::Evaluation::ModelInput)
|
|
177
180
|
end
|
|
@@ -227,8 +230,8 @@ module Deeprails
|
|
|
227
230
|
sig { params(evaluation_total_cost: Float).void }
|
|
228
231
|
attr_writer :evaluation_total_cost
|
|
229
232
|
|
|
230
|
-
# An array of guardrail metrics that the
|
|
231
|
-
#
|
|
233
|
+
# An array of guardrail metrics that the input and output pair will be evaluated
|
|
234
|
+
# on.
|
|
232
235
|
sig do
|
|
233
236
|
returns(
|
|
234
237
|
T.nilable(
|
|
@@ -290,8 +293,9 @@ module Deeprails
|
|
|
290
293
|
# Status of the evaluation.
|
|
291
294
|
evaluation_status:,
|
|
292
295
|
# A dictionary of inputs sent to the LLM to generate output. The dictionary must
|
|
293
|
-
# contain
|
|
294
|
-
#
|
|
296
|
+
# contain a `user_prompt` field. For ground_truth_adherence guardrail metric,
|
|
297
|
+
# `ground_truth` should be provided. When `context_awareness` is enabled,
|
|
298
|
+
# `context` should be provided.
|
|
295
299
|
model_input:,
|
|
296
300
|
# Output generated by the LLM to be evaluated.
|
|
297
301
|
model_output:,
|
|
@@ -307,8 +311,8 @@ module Deeprails
|
|
|
307
311
|
evaluation_result: nil,
|
|
308
312
|
# Total cost of the evaluation.
|
|
309
313
|
evaluation_total_cost: nil,
|
|
310
|
-
# An array of guardrail metrics that the
|
|
311
|
-
#
|
|
314
|
+
# An array of guardrail metrics that the input and output pair will be evaluated
|
|
315
|
+
# on.
|
|
312
316
|
guardrail_metrics: nil,
|
|
313
317
|
# An optional, user-defined tag for the evaluation.
|
|
314
318
|
nametag: nil,
|
|
@@ -403,6 +407,36 @@ module Deeprails
|
|
|
403
407
|
)
|
|
404
408
|
end
|
|
405
409
|
|
|
410
|
+
# The user prompt used to generate the output.
|
|
411
|
+
sig { returns(String) }
|
|
412
|
+
attr_accessor :user_prompt
|
|
413
|
+
|
|
414
|
+
# Any structured information that directly relates to the model’s input and
|
|
415
|
+
# expected output—e.g., the recent turn-by-turn history between an AI tutor and a
|
|
416
|
+
# student, facts or state passed through an agentic workflow, or other
|
|
417
|
+
# domain-specific signals your system already knows and wants the model to
|
|
418
|
+
# condition on.
|
|
419
|
+
sig do
|
|
420
|
+
returns(
|
|
421
|
+
T.nilable(
|
|
422
|
+
T::Array[
|
|
423
|
+
Deeprails::MonitorDetailResponse::Evaluation::ModelInput::Context
|
|
424
|
+
]
|
|
425
|
+
)
|
|
426
|
+
)
|
|
427
|
+
end
|
|
428
|
+
attr_reader :context
|
|
429
|
+
|
|
430
|
+
sig do
|
|
431
|
+
params(
|
|
432
|
+
context:
|
|
433
|
+
T::Array[
|
|
434
|
+
Deeprails::MonitorDetailResponse::Evaluation::ModelInput::Context::OrHash
|
|
435
|
+
]
|
|
436
|
+
).void
|
|
437
|
+
end
|
|
438
|
+
attr_writer :context
|
|
439
|
+
|
|
406
440
|
# The ground truth for evaluating Ground Truth Adherence guardrail.
|
|
407
441
|
sig { returns(T.nilable(String)) }
|
|
408
442
|
attr_reader :ground_truth
|
|
@@ -417,44 +451,91 @@ module Deeprails
|
|
|
417
451
|
sig { params(system_prompt: String).void }
|
|
418
452
|
attr_writer :system_prompt
|
|
419
453
|
|
|
420
|
-
# The user prompt used to generate the output.
|
|
421
|
-
sig { returns(T.nilable(String)) }
|
|
422
|
-
attr_reader :user_prompt
|
|
423
|
-
|
|
424
|
-
sig { params(user_prompt: String).void }
|
|
425
|
-
attr_writer :user_prompt
|
|
426
|
-
|
|
427
454
|
# A dictionary of inputs sent to the LLM to generate output. The dictionary must
|
|
428
|
-
# contain
|
|
429
|
-
#
|
|
455
|
+
# contain a `user_prompt` field. For ground_truth_adherence guardrail metric,
|
|
456
|
+
# `ground_truth` should be provided. When `context_awareness` is enabled,
|
|
457
|
+
# `context` should be provided.
|
|
430
458
|
sig do
|
|
431
459
|
params(
|
|
460
|
+
user_prompt: String,
|
|
461
|
+
context:
|
|
462
|
+
T::Array[
|
|
463
|
+
Deeprails::MonitorDetailResponse::Evaluation::ModelInput::Context::OrHash
|
|
464
|
+
],
|
|
432
465
|
ground_truth: String,
|
|
433
|
-
system_prompt: String
|
|
434
|
-
user_prompt: String
|
|
466
|
+
system_prompt: String
|
|
435
467
|
).returns(T.attached_class)
|
|
436
468
|
end
|
|
437
469
|
def self.new(
|
|
470
|
+
# The user prompt used to generate the output.
|
|
471
|
+
user_prompt:,
|
|
472
|
+
# Any structured information that directly relates to the model’s input and
|
|
473
|
+
# expected output—e.g., the recent turn-by-turn history between an AI tutor and a
|
|
474
|
+
# student, facts or state passed through an agentic workflow, or other
|
|
475
|
+
# domain-specific signals your system already knows and wants the model to
|
|
476
|
+
# condition on.
|
|
477
|
+
context: nil,
|
|
438
478
|
# The ground truth for evaluating Ground Truth Adherence guardrail.
|
|
439
479
|
ground_truth: nil,
|
|
440
480
|
# The system prompt used to generate the output.
|
|
441
|
-
system_prompt: nil
|
|
442
|
-
# The user prompt used to generate the output.
|
|
443
|
-
user_prompt: nil
|
|
481
|
+
system_prompt: nil
|
|
444
482
|
)
|
|
445
483
|
end
|
|
446
484
|
|
|
447
485
|
sig do
|
|
448
486
|
override.returns(
|
|
449
487
|
{
|
|
488
|
+
user_prompt: String,
|
|
489
|
+
context:
|
|
490
|
+
T::Array[
|
|
491
|
+
Deeprails::MonitorDetailResponse::Evaluation::ModelInput::Context
|
|
492
|
+
],
|
|
450
493
|
ground_truth: String,
|
|
451
|
-
system_prompt: String
|
|
452
|
-
user_prompt: String
|
|
494
|
+
system_prompt: String
|
|
453
495
|
}
|
|
454
496
|
)
|
|
455
497
|
end
|
|
456
498
|
def to_hash
|
|
457
499
|
end
|
|
500
|
+
|
|
501
|
+
class Context < Deeprails::Internal::Type::BaseModel
|
|
502
|
+
OrHash =
|
|
503
|
+
T.type_alias do
|
|
504
|
+
T.any(
|
|
505
|
+
Deeprails::MonitorDetailResponse::Evaluation::ModelInput::Context,
|
|
506
|
+
Deeprails::Internal::AnyHash
|
|
507
|
+
)
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
# The content of the message.
|
|
511
|
+
sig { returns(T.nilable(String)) }
|
|
512
|
+
attr_reader :content
|
|
513
|
+
|
|
514
|
+
sig { params(content: String).void }
|
|
515
|
+
attr_writer :content
|
|
516
|
+
|
|
517
|
+
# The role of the speaker.
|
|
518
|
+
sig { returns(T.nilable(String)) }
|
|
519
|
+
attr_reader :role
|
|
520
|
+
|
|
521
|
+
sig { params(role: String).void }
|
|
522
|
+
attr_writer :role
|
|
523
|
+
|
|
524
|
+
sig do
|
|
525
|
+
params(content: String, role: String).returns(T.attached_class)
|
|
526
|
+
end
|
|
527
|
+
def self.new(
|
|
528
|
+
# The content of the message.
|
|
529
|
+
content: nil,
|
|
530
|
+
# The role of the speaker.
|
|
531
|
+
role: nil
|
|
532
|
+
)
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
sig { override.returns({ content: String, role: String }) }
|
|
536
|
+
def to_hash
|
|
537
|
+
end
|
|
538
|
+
end
|
|
458
539
|
end
|
|
459
540
|
|
|
460
541
|
# Run mode for the evaluation. The run mode allows the user to optimize for speed,
|
|
@@ -11,7 +11,8 @@ module Deeprails
|
|
|
11
11
|
)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
# The capabilities associated with the monitor event.
|
|
14
|
+
# The extended AI capabilities associated with the monitor event. Can be
|
|
15
|
+
# `web_search`, `file_search`, and/or `context_awareness`.
|
|
15
16
|
sig do
|
|
16
17
|
returns(
|
|
17
18
|
T.nilable(T::Array[Deeprails::MonitorEventDetailResponse::Capability])
|
|
@@ -156,7 +157,8 @@ module Deeprails
|
|
|
156
157
|
).returns(T.attached_class)
|
|
157
158
|
end
|
|
158
159
|
def self.new(
|
|
159
|
-
# The capabilities associated with the monitor event.
|
|
160
|
+
# The extended AI capabilities associated with the monitor event. Can be
|
|
161
|
+
# `web_search`, `file_search`, and/or `context_awareness`.
|
|
160
162
|
capabilities: nil,
|
|
161
163
|
# The time spent on the evaluation in seconds.
|
|
162
164
|
eval_time: nil,
|