deeprails 0.11.0 → 0.12.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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/README.md +26 -40
  4. data/lib/deeprails/internal/transport/base_client.rb +7 -1
  5. data/lib/deeprails/internal/transport/pooled_net_requester.rb +6 -2
  6. data/lib/deeprails/internal/type/base_model.rb +5 -5
  7. data/lib/deeprails/models/defend_create_response.rb +51 -0
  8. data/lib/deeprails/models/defend_create_workflow_params.rb +19 -19
  9. data/lib/deeprails/models/defend_response.rb +278 -38
  10. data/lib/deeprails/models/defend_retrieve_workflow_params.rb +13 -1
  11. data/lib/deeprails/models/defend_update_response.rb +51 -0
  12. data/lib/deeprails/models/file_response.rb +6 -22
  13. data/lib/deeprails/models/file_upload_params.rb +3 -3
  14. data/lib/deeprails/models/monitor_create_response.rb +51 -0
  15. data/lib/deeprails/models/monitor_detail_response.rb +69 -70
  16. data/lib/deeprails/models/monitor_event_detail_response.rb +182 -0
  17. data/lib/deeprails/models/monitor_event_response.rb +1 -9
  18. data/lib/deeprails/models/monitor_retrieve_params.rb +6 -2
  19. data/lib/deeprails/models/monitor_update_params.rb +11 -11
  20. data/lib/deeprails/models/monitor_update_response.rb +51 -0
  21. data/lib/deeprails/models/workflow_event_detail_response.rb +314 -0
  22. data/lib/deeprails/models/workflow_event_response.rb +29 -30
  23. data/lib/deeprails/models.rb +12 -2
  24. data/lib/deeprails/resources/defend.rb +20 -13
  25. data/lib/deeprails/resources/files.rb +1 -1
  26. data/lib/deeprails/resources/monitor.rb +11 -8
  27. data/lib/deeprails/version.rb +1 -1
  28. data/lib/deeprails.rb +7 -1
  29. data/manifest.yaml +1 -0
  30. data/rbi/deeprails/internal/transport/base_client.rbi +5 -0
  31. data/rbi/deeprails/internal/transport/pooled_net_requester.rbi +6 -2
  32. data/rbi/deeprails/internal/type/base_model.rbi +8 -4
  33. data/rbi/deeprails/models/defend_create_response.rbi +83 -0
  34. data/rbi/deeprails/models/defend_create_workflow_params.rbi +33 -27
  35. data/rbi/deeprails/models/defend_response.rbi +555 -72
  36. data/rbi/deeprails/models/defend_retrieve_workflow_params.rbi +23 -5
  37. data/rbi/deeprails/models/defend_update_response.rbi +83 -0
  38. data/rbi/deeprails/models/file_response.rbi +11 -39
  39. data/rbi/deeprails/models/file_upload_params.rbi +3 -6
  40. data/rbi/deeprails/models/monitor_create_response.rbi +83 -0
  41. data/rbi/deeprails/models/monitor_detail_response.rbi +144 -104
  42. data/rbi/deeprails/models/monitor_event_detail_response.rbi +383 -0
  43. data/rbi/deeprails/models/monitor_event_response.rbi +4 -18
  44. data/rbi/deeprails/models/monitor_retrieve_params.rbi +4 -2
  45. data/rbi/deeprails/models/monitor_update_params.rbi +21 -38
  46. data/rbi/deeprails/models/monitor_update_response.rbi +83 -0
  47. data/rbi/deeprails/models/workflow_event_detail_response.rbi +685 -0
  48. data/rbi/deeprails/models/workflow_event_response.rbi +49 -42
  49. data/rbi/deeprails/models.rbi +12 -2
  50. data/rbi/deeprails/resources/defend.rbi +17 -12
  51. data/rbi/deeprails/resources/files.rbi +1 -1
  52. data/rbi/deeprails/resources/monitor.rbi +8 -8
  53. data/sig/deeprails/internal/transport/base_client.rbs +2 -0
  54. data/sig/deeprails/internal/transport/pooled_net_requester.rbs +4 -1
  55. data/sig/deeprails/models/defend_create_response.rbs +41 -0
  56. data/sig/deeprails/models/defend_create_workflow_params.rbs +7 -7
  57. data/sig/deeprails/models/defend_response.rbs +297 -28
  58. data/sig/deeprails/models/defend_retrieve_workflow_params.rbs +13 -3
  59. data/sig/deeprails/models/defend_update_response.rbs +41 -0
  60. data/sig/deeprails/models/file_response.rbs +5 -27
  61. data/sig/deeprails/models/file_upload_params.rbs +4 -5
  62. data/sig/deeprails/models/monitor_create_response.rbs +41 -0
  63. data/sig/deeprails/models/monitor_detail_response.rbs +72 -61
  64. data/sig/deeprails/models/monitor_event_detail_response.rbs +181 -0
  65. data/sig/deeprails/models/monitor_event_response.rbs +2 -15
  66. data/sig/deeprails/models/monitor_update_params.rbs +13 -13
  67. data/sig/deeprails/models/monitor_update_response.rbs +41 -0
  68. data/sig/deeprails/models/workflow_event_detail_response.rbs +315 -0
  69. data/sig/deeprails/models/workflow_event_response.rbs +24 -24
  70. data/sig/deeprails/models.rbs +12 -2
  71. data/sig/deeprails/resources/defend.rbs +5 -4
  72. data/sig/deeprails/resources/files.rbs +1 -1
  73. data/sig/deeprails/resources/monitor.rbs +3 -3
  74. metadata +20 -5
  75. data/lib/deeprails/models/monitor_response.rb +0 -83
  76. data/rbi/deeprails/models/monitor_response.rbi +0 -142
  77. data/sig/deeprails/models/monitor_response.rbs +0 -73
@@ -16,6 +16,45 @@ module Deeprails
16
16
  sig { returns(String) }
17
17
  attr_accessor :workflow_id
18
18
 
19
+ # Mapping of guardrail metric names to tolerance values. Values can be strings
20
+ # (`low`, `medium`, `high`) for automatic tolerance levels.
21
+ sig do
22
+ returns(
23
+ T.nilable(
24
+ T::Hash[
25
+ Symbol,
26
+ Deeprails::DefendResponse::AutomaticHallucinationToleranceLevel::TaggedSymbol
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::DefendResponse::AutomaticHallucinationToleranceLevel::OrSymbol
39
+ ]
40
+ ).void
41
+ end
42
+ attr_writer :automatic_hallucination_tolerance_levels
43
+
44
+ # Extended AI capabilities available to the event, if any. Can be `web_search`
45
+ # and/or `file_search`.
46
+ sig do
47
+ returns(T.nilable(T::Array[Deeprails::DefendResponse::Capability]))
48
+ end
49
+ attr_reader :capabilities
50
+
51
+ sig do
52
+ params(
53
+ capabilities: T::Array[Deeprails::DefendResponse::Capability::OrHash]
54
+ ).void
55
+ end
56
+ attr_writer :capabilities
57
+
19
58
  # The time the workflow was created in UTC.
20
59
  sig { returns(T.nilable(Time)) }
21
60
  attr_reader :created_at
@@ -23,6 +62,18 @@ module Deeprails
23
62
  sig { params(created_at: Time).void }
24
63
  attr_writer :created_at
25
64
 
65
+ # Mapping of guardrail metric names to threshold values. Values can be floating
66
+ # point numbers (0.0-1.0) for custom thresholds.
67
+ sig { returns(T.nilable(T::Hash[Symbol, Float])) }
68
+ attr_reader :custom_hallucination_threshold_values
69
+
70
+ sig do
71
+ params(
72
+ custom_hallucination_threshold_values: T::Hash[Symbol, Float]
73
+ ).void
74
+ end
75
+ attr_writer :custom_hallucination_threshold_values
76
+
26
77
  # Description for the workflow.
27
78
  sig { returns(T.nilable(String)) }
28
79
  attr_reader :description
@@ -30,40 +81,30 @@ module Deeprails
30
81
  sig { params(description: String).void }
31
82
  attr_writer :description
32
83
 
33
- # The action used to improve outputs that fail one or more guardrail metrics for
34
- # the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs the
35
- # user's input prompt with minor induced variance. FixIt attempts to directly
36
- # address the shortcomings of the output using the guardrail failure rationale. Do
37
- # Nothing does not attempt any improvement.
38
- sig do
39
- returns(
40
- T.nilable(Deeprails::DefendResponse::ImprovementAction::TaggedSymbol)
41
- )
42
- end
43
- attr_reader :improvement_action
84
+ # An array of events associated with this workflow.
85
+ sig { returns(T.nilable(T::Array[Deeprails::DefendResponse::Event])) }
86
+ attr_reader :events
44
87
 
45
88
  sig do
46
- params(
47
- improvement_action:
48
- Deeprails::DefendResponse::ImprovementAction::OrSymbol
49
- ).void
89
+ params(events: T::Array[Deeprails::DefendResponse::Event::OrHash]).void
50
90
  end
51
- attr_writer :improvement_action
91
+ attr_writer :events
52
92
 
53
- # Max. number of improvement action retries until a given event passes the
54
- # guardrails.
55
- sig { returns(T.nilable(Integer)) }
56
- attr_reader :max_improvement_attempts
93
+ # List of files associated with the workflow. If this is not empty, models can
94
+ # search these files when performing evaluations or remediations
95
+ sig { returns(T.nilable(T::Array[Deeprails::DefendResponse::File])) }
96
+ attr_reader :files
57
97
 
58
- sig { params(max_improvement_attempts: Integer).void }
59
- attr_writer :max_improvement_attempts
98
+ sig do
99
+ params(files: T::Array[Deeprails::DefendResponse::File::OrHash]).void
100
+ end
101
+ attr_writer :files
60
102
 
61
- # The most recent time the workflow was modified in UTC.
62
- sig { returns(T.nilable(Time)) }
63
- attr_reader :modified_at
103
+ sig { returns(T.nilable(Deeprails::DefendResponse::Stats)) }
104
+ attr_reader :stats
64
105
 
65
- sig { params(modified_at: Time).void }
66
- attr_writer :modified_at
106
+ sig { params(stats: Deeprails::DefendResponse::Stats::OrHash).void }
107
+ attr_writer :stats
67
108
 
68
109
  # Status of the selected workflow. May be `inactive` or `active`. Inactive
69
110
  # workflows will not accept events.
@@ -75,25 +116,47 @@ module Deeprails
75
116
  sig { params(status: Deeprails::DefendResponse::Status::OrSymbol).void }
76
117
  attr_writer :status
77
118
 
78
- # Rate of events associated with this workflow that passed evaluation.
79
- sig { returns(T.nilable(Float)) }
80
- attr_reader :success_rate
119
+ # Type of thresholds used to evaluate the event.
120
+ sig do
121
+ returns(
122
+ T.nilable(Deeprails::DefendResponse::ThresholdType::TaggedSymbol)
123
+ )
124
+ end
125
+ attr_reader :threshold_type
126
+
127
+ sig do
128
+ params(
129
+ threshold_type: Deeprails::DefendResponse::ThresholdType::OrSymbol
130
+ ).void
131
+ end
132
+ attr_writer :threshold_type
133
+
134
+ # The most recent time the workflow was updated in UTC.
135
+ sig { returns(T.nilable(Time)) }
136
+ attr_reader :updated_at
81
137
 
82
- sig { params(success_rate: Float).void }
83
- attr_writer :success_rate
138
+ sig { params(updated_at: Time).void }
139
+ attr_writer :updated_at
84
140
 
85
141
  sig do
86
142
  params(
87
143
  name: String,
88
144
  workflow_id: String,
145
+ automatic_hallucination_tolerance_levels:
146
+ T::Hash[
147
+ Symbol,
148
+ Deeprails::DefendResponse::AutomaticHallucinationToleranceLevel::OrSymbol
149
+ ],
150
+ capabilities: T::Array[Deeprails::DefendResponse::Capability::OrHash],
89
151
  created_at: Time,
152
+ custom_hallucination_threshold_values: T::Hash[Symbol, Float],
90
153
  description: String,
91
- improvement_action:
92
- Deeprails::DefendResponse::ImprovementAction::OrSymbol,
93
- max_improvement_attempts: Integer,
94
- modified_at: Time,
154
+ events: T::Array[Deeprails::DefendResponse::Event::OrHash],
155
+ files: T::Array[Deeprails::DefendResponse::File::OrHash],
156
+ stats: Deeprails::DefendResponse::Stats::OrHash,
95
157
  status: Deeprails::DefendResponse::Status::OrSymbol,
96
- success_rate: Float
158
+ threshold_type: Deeprails::DefendResponse::ThresholdType::OrSymbol,
159
+ updated_at: Time
97
160
  ).returns(T.attached_class)
98
161
  end
99
162
  def self.new(
@@ -101,26 +164,32 @@ module Deeprails
101
164
  name:,
102
165
  # A unique workflow ID.
103
166
  workflow_id:,
167
+ # Mapping of guardrail metric names to tolerance values. Values can be strings
168
+ # (`low`, `medium`, `high`) for automatic tolerance levels.
169
+ automatic_hallucination_tolerance_levels: nil,
170
+ # Extended AI capabilities available to the event, if any. Can be `web_search`
171
+ # and/or `file_search`.
172
+ capabilities: nil,
104
173
  # The time the workflow was created in UTC.
105
174
  created_at: nil,
175
+ # Mapping of guardrail metric names to threshold values. Values can be floating
176
+ # point numbers (0.0-1.0) for custom thresholds.
177
+ custom_hallucination_threshold_values: nil,
106
178
  # Description for the workflow.
107
179
  description: nil,
108
- # The action used to improve outputs that fail one or more guardrail metrics for
109
- # the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs the
110
- # user's input prompt with minor induced variance. FixIt attempts to directly
111
- # address the shortcomings of the output using the guardrail failure rationale. Do
112
- # Nothing does not attempt any improvement.
113
- improvement_action: nil,
114
- # Max. number of improvement action retries until a given event passes the
115
- # guardrails.
116
- max_improvement_attempts: nil,
117
- # The most recent time the workflow was modified in UTC.
118
- modified_at: nil,
180
+ # An array of events associated with this workflow.
181
+ events: nil,
182
+ # List of files associated with the workflow. If this is not empty, models can
183
+ # search these files when performing evaluations or remediations
184
+ files: nil,
185
+ stats: nil,
119
186
  # Status of the selected workflow. May be `inactive` or `active`. Inactive
120
187
  # workflows will not accept events.
121
188
  status: nil,
122
- # Rate of events associated with this workflow that passed evaluation.
123
- success_rate: nil
189
+ # Type of thresholds used to evaluate the event.
190
+ threshold_type: nil,
191
+ # The most recent time the workflow was updated in UTC.
192
+ updated_at: nil
124
193
  )
125
194
  end
126
195
 
@@ -129,59 +198,446 @@ module Deeprails
129
198
  {
130
199
  name: String,
131
200
  workflow_id: String,
201
+ automatic_hallucination_tolerance_levels:
202
+ T::Hash[
203
+ Symbol,
204
+ Deeprails::DefendResponse::AutomaticHallucinationToleranceLevel::TaggedSymbol
205
+ ],
206
+ capabilities: T::Array[Deeprails::DefendResponse::Capability],
132
207
  created_at: Time,
208
+ custom_hallucination_threshold_values: T::Hash[Symbol, Float],
133
209
  description: String,
134
- improvement_action:
135
- Deeprails::DefendResponse::ImprovementAction::TaggedSymbol,
136
- max_improvement_attempts: Integer,
137
- modified_at: Time,
210
+ events: T::Array[Deeprails::DefendResponse::Event],
211
+ files: T::Array[Deeprails::DefendResponse::File],
212
+ stats: Deeprails::DefendResponse::Stats,
138
213
  status: Deeprails::DefendResponse::Status::TaggedSymbol,
139
- success_rate: Float
214
+ threshold_type:
215
+ Deeprails::DefendResponse::ThresholdType::TaggedSymbol,
216
+ updated_at: Time
140
217
  }
141
218
  )
142
219
  end
143
220
  def to_hash
144
221
  end
145
222
 
146
- # The action used to improve outputs that fail one or more guardrail metrics for
147
- # the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs the
148
- # user's input prompt with minor induced variance. FixIt attempts to directly
149
- # address the shortcomings of the output using the guardrail failure rationale. Do
150
- # Nothing does not attempt any improvement.
151
- module ImprovementAction
223
+ module AutomaticHallucinationToleranceLevel
152
224
  extend Deeprails::Internal::Type::Enum
153
225
 
154
226
  TaggedSymbol =
155
227
  T.type_alias do
156
- T.all(Symbol, Deeprails::DefendResponse::ImprovementAction)
228
+ T.all(
229
+ Symbol,
230
+ Deeprails::DefendResponse::AutomaticHallucinationToleranceLevel
231
+ )
157
232
  end
158
233
  OrSymbol = T.type_alias { T.any(Symbol, String) }
159
234
 
160
- REGEN =
235
+ LOW =
161
236
  T.let(
162
- :regen,
163
- Deeprails::DefendResponse::ImprovementAction::TaggedSymbol
237
+ :low,
238
+ Deeprails::DefendResponse::AutomaticHallucinationToleranceLevel::TaggedSymbol
164
239
  )
165
- FIXIT =
240
+ MEDIUM =
166
241
  T.let(
167
- :fixit,
168
- Deeprails::DefendResponse::ImprovementAction::TaggedSymbol
242
+ :medium,
243
+ Deeprails::DefendResponse::AutomaticHallucinationToleranceLevel::TaggedSymbol
169
244
  )
170
- DO_NOTHING =
245
+ HIGH =
171
246
  T.let(
172
- :do_nothing,
173
- Deeprails::DefendResponse::ImprovementAction::TaggedSymbol
247
+ :high,
248
+ Deeprails::DefendResponse::AutomaticHallucinationToleranceLevel::TaggedSymbol
174
249
  )
175
250
 
176
251
  sig do
177
252
  override.returns(
178
- T::Array[Deeprails::DefendResponse::ImprovementAction::TaggedSymbol]
253
+ T::Array[
254
+ Deeprails::DefendResponse::AutomaticHallucinationToleranceLevel::TaggedSymbol
255
+ ]
179
256
  )
180
257
  end
181
258
  def self.values
182
259
  end
183
260
  end
184
261
 
262
+ class Capability < Deeprails::Internal::Type::BaseModel
263
+ OrHash =
264
+ T.type_alias do
265
+ T.any(
266
+ Deeprails::DefendResponse::Capability,
267
+ Deeprails::Internal::AnyHash
268
+ )
269
+ end
270
+
271
+ sig { returns(T.nilable(String)) }
272
+ attr_reader :capability
273
+
274
+ sig { params(capability: String).void }
275
+ attr_writer :capability
276
+
277
+ sig { params(capability: String).returns(T.attached_class) }
278
+ def self.new(capability: nil)
279
+ end
280
+
281
+ sig { override.returns({ capability: String }) }
282
+ def to_hash
283
+ end
284
+ end
285
+
286
+ class Event < Deeprails::Internal::Type::BaseModel
287
+ OrHash =
288
+ T.type_alias do
289
+ T.any(
290
+ Deeprails::DefendResponse::Event,
291
+ Deeprails::Internal::AnyHash
292
+ )
293
+ end
294
+
295
+ # An array of evaluations for this event.
296
+ sig do
297
+ returns(
298
+ T.nilable(T::Array[Deeprails::DefendResponse::Event::Evaluation])
299
+ )
300
+ end
301
+ attr_reader :evaluations
302
+
303
+ sig do
304
+ params(
305
+ evaluations:
306
+ T::Array[Deeprails::DefendResponse::Event::Evaluation::OrHash]
307
+ ).void
308
+ end
309
+ attr_writer :evaluations
310
+
311
+ # A unique workflow event ID.
312
+ sig { returns(T.nilable(String)) }
313
+ attr_reader :event_id
314
+
315
+ sig { params(event_id: String).void }
316
+ attr_writer :event_id
317
+
318
+ # Improved model output after improvement tool was applied.
319
+ sig { returns(T.nilable(String)) }
320
+ attr_reader :improved_model_output
321
+
322
+ sig { params(improved_model_output: String).void }
323
+ attr_writer :improved_model_output
324
+
325
+ # Status of the improvement tool used to improve the event.
326
+ sig { returns(T.nilable(String)) }
327
+ attr_reader :improvement_tool_status
328
+
329
+ sig { params(improvement_tool_status: String).void }
330
+ attr_writer :improvement_tool_status
331
+
332
+ sig do
333
+ params(
334
+ evaluations:
335
+ T::Array[Deeprails::DefendResponse::Event::Evaluation::OrHash],
336
+ event_id: String,
337
+ improved_model_output: String,
338
+ improvement_tool_status: String
339
+ ).returns(T.attached_class)
340
+ end
341
+ def self.new(
342
+ # An array of evaluations for this event.
343
+ evaluations: nil,
344
+ # A unique workflow event ID.
345
+ event_id: nil,
346
+ # Improved model output after improvement tool was applied.
347
+ improved_model_output: nil,
348
+ # Status of the improvement tool used to improve the event.
349
+ improvement_tool_status: nil
350
+ )
351
+ end
352
+
353
+ sig do
354
+ override.returns(
355
+ {
356
+ evaluations:
357
+ T::Array[Deeprails::DefendResponse::Event::Evaluation],
358
+ event_id: String,
359
+ improved_model_output: String,
360
+ improvement_tool_status: String
361
+ }
362
+ )
363
+ end
364
+ def to_hash
365
+ end
366
+
367
+ class Evaluation < Deeprails::Internal::Type::BaseModel
368
+ OrHash =
369
+ T.type_alias do
370
+ T.any(
371
+ Deeprails::DefendResponse::Event::Evaluation,
372
+ Deeprails::Internal::AnyHash
373
+ )
374
+ end
375
+
376
+ # The attempt number or identifier for this evaluation.
377
+ sig { returns(T.nilable(String)) }
378
+ attr_reader :attempt
379
+
380
+ sig { params(attempt: String).void }
381
+ attr_writer :attempt
382
+
383
+ # The time the evaluation was created in UTC.
384
+ sig { returns(T.nilable(Time)) }
385
+ attr_reader :created_at
386
+
387
+ sig { params(created_at: Time).void }
388
+ attr_writer :created_at
389
+
390
+ # Error message if the evaluation failed.
391
+ sig { returns(T.nilable(String)) }
392
+ attr_reader :error_message
393
+
394
+ sig { params(error_message: String).void }
395
+ attr_writer :error_message
396
+
397
+ # The result of the evaluation.
398
+ sig { returns(T.nilable(T::Hash[Symbol, T.anything])) }
399
+ attr_reader :evaluation_result
400
+
401
+ sig { params(evaluation_result: T::Hash[Symbol, T.anything]).void }
402
+ attr_writer :evaluation_result
403
+
404
+ # Status of the evaluation.
405
+ sig { returns(T.nilable(String)) }
406
+ attr_reader :evaluation_status
407
+
408
+ sig { params(evaluation_status: String).void }
409
+ attr_writer :evaluation_status
410
+
411
+ # Total cost of the evaluation.
412
+ sig { returns(T.nilable(Float)) }
413
+ attr_reader :evaluation_total_cost
414
+
415
+ sig { params(evaluation_total_cost: Float).void }
416
+ attr_writer :evaluation_total_cost
417
+
418
+ # An array of guardrail metrics evaluated.
419
+ sig { returns(T.nilable(T::Array[String])) }
420
+ attr_reader :guardrail_metrics
421
+
422
+ sig { params(guardrail_metrics: T::Array[String]).void }
423
+ attr_writer :guardrail_metrics
424
+
425
+ # The model input used for the evaluation.
426
+ sig { returns(T.nilable(T::Hash[Symbol, T.anything])) }
427
+ attr_reader :model_input
428
+
429
+ sig { params(model_input: T::Hash[Symbol, T.anything]).void }
430
+ attr_writer :model_input
431
+
432
+ # The model output that was evaluated.
433
+ sig { returns(T.nilable(String)) }
434
+ attr_reader :model_output
435
+
436
+ sig { params(model_output: String).void }
437
+ attr_writer :model_output
438
+
439
+ # The time the evaluation was last modified in UTC.
440
+ sig { returns(T.nilable(Time)) }
441
+ attr_reader :modified_at
442
+
443
+ sig { params(modified_at: Time).void }
444
+ attr_writer :modified_at
445
+
446
+ # An optional tag for the evaluation.
447
+ sig { returns(T.nilable(String)) }
448
+ attr_reader :nametag
449
+
450
+ sig { params(nametag: String).void }
451
+ attr_writer :nametag
452
+
453
+ # Evaluation progress (0-100).
454
+ sig { returns(T.nilable(Integer)) }
455
+ attr_reader :progress
456
+
457
+ sig { params(progress: Integer).void }
458
+ attr_writer :progress
459
+
460
+ # Run mode used for the evaluation.
461
+ sig { returns(T.nilable(String)) }
462
+ attr_reader :run_mode
463
+
464
+ sig { params(run_mode: String).void }
465
+ attr_writer :run_mode
466
+
467
+ sig do
468
+ params(
469
+ attempt: String,
470
+ created_at: Time,
471
+ error_message: String,
472
+ evaluation_result: T::Hash[Symbol, T.anything],
473
+ evaluation_status: String,
474
+ evaluation_total_cost: Float,
475
+ guardrail_metrics: T::Array[String],
476
+ model_input: T::Hash[Symbol, T.anything],
477
+ model_output: String,
478
+ modified_at: Time,
479
+ nametag: String,
480
+ progress: Integer,
481
+ run_mode: String
482
+ ).returns(T.attached_class)
483
+ end
484
+ def self.new(
485
+ # The attempt number or identifier for this evaluation.
486
+ attempt: nil,
487
+ # The time the evaluation was created in UTC.
488
+ created_at: nil,
489
+ # Error message if the evaluation failed.
490
+ error_message: nil,
491
+ # The result of the evaluation.
492
+ evaluation_result: nil,
493
+ # Status of the evaluation.
494
+ evaluation_status: nil,
495
+ # Total cost of the evaluation.
496
+ evaluation_total_cost: nil,
497
+ # An array of guardrail metrics evaluated.
498
+ guardrail_metrics: nil,
499
+ # The model input used for the evaluation.
500
+ model_input: nil,
501
+ # The model output that was evaluated.
502
+ model_output: nil,
503
+ # The time the evaluation was last modified in UTC.
504
+ modified_at: nil,
505
+ # An optional tag for the evaluation.
506
+ nametag: nil,
507
+ # Evaluation progress (0-100).
508
+ progress: nil,
509
+ # Run mode used for the evaluation.
510
+ run_mode: nil
511
+ )
512
+ end
513
+
514
+ sig do
515
+ override.returns(
516
+ {
517
+ attempt: String,
518
+ created_at: Time,
519
+ error_message: String,
520
+ evaluation_result: T::Hash[Symbol, T.anything],
521
+ evaluation_status: String,
522
+ evaluation_total_cost: Float,
523
+ guardrail_metrics: T::Array[String],
524
+ model_input: T::Hash[Symbol, T.anything],
525
+ model_output: String,
526
+ modified_at: Time,
527
+ nametag: String,
528
+ progress: Integer,
529
+ run_mode: String
530
+ }
531
+ )
532
+ end
533
+ def to_hash
534
+ end
535
+ end
536
+ end
537
+
538
+ class File < Deeprails::Internal::Type::BaseModel
539
+ OrHash =
540
+ T.type_alias do
541
+ T.any(Deeprails::DefendResponse::File, Deeprails::Internal::AnyHash)
542
+ end
543
+
544
+ sig { returns(T.nilable(String)) }
545
+ attr_reader :file_id
546
+
547
+ sig { params(file_id: String).void }
548
+ attr_writer :file_id
549
+
550
+ sig { returns(T.nilable(String)) }
551
+ attr_reader :file_name
552
+
553
+ sig { params(file_name: String).void }
554
+ attr_writer :file_name
555
+
556
+ sig { returns(T.nilable(Integer)) }
557
+ attr_reader :file_size
558
+
559
+ sig { params(file_size: Integer).void }
560
+ attr_writer :file_size
561
+
562
+ sig do
563
+ params(
564
+ file_id: String,
565
+ file_name: String,
566
+ file_size: Integer
567
+ ).returns(T.attached_class)
568
+ end
569
+ def self.new(file_id: nil, file_name: nil, file_size: nil)
570
+ end
571
+
572
+ sig do
573
+ override.returns(
574
+ { file_id: String, file_name: String, file_size: Integer }
575
+ )
576
+ end
577
+ def to_hash
578
+ end
579
+ end
580
+
581
+ class Stats < Deeprails::Internal::Type::BaseModel
582
+ OrHash =
583
+ T.type_alias do
584
+ T.any(
585
+ Deeprails::DefendResponse::Stats,
586
+ Deeprails::Internal::AnyHash
587
+ )
588
+ end
589
+
590
+ # Number of AI outputs that failed the guardrails.
591
+ sig { returns(T.nilable(Integer)) }
592
+ attr_reader :outputs_below_threshold
593
+
594
+ sig { params(outputs_below_threshold: Integer).void }
595
+ attr_writer :outputs_below_threshold
596
+
597
+ # Number of AI outputs that were improved.
598
+ sig { returns(T.nilable(Integer)) }
599
+ attr_reader :outputs_improved
600
+
601
+ sig { params(outputs_improved: Integer).void }
602
+ attr_writer :outputs_improved
603
+
604
+ # Total number of AI outputs processed by the workflow.
605
+ sig { returns(T.nilable(Integer)) }
606
+ attr_reader :outputs_processed
607
+
608
+ sig { params(outputs_processed: Integer).void }
609
+ attr_writer :outputs_processed
610
+
611
+ sig do
612
+ params(
613
+ outputs_below_threshold: Integer,
614
+ outputs_improved: Integer,
615
+ outputs_processed: Integer
616
+ ).returns(T.attached_class)
617
+ end
618
+ def self.new(
619
+ # Number of AI outputs that failed the guardrails.
620
+ outputs_below_threshold: nil,
621
+ # Number of AI outputs that were improved.
622
+ outputs_improved: nil,
623
+ # Total number of AI outputs processed by the workflow.
624
+ outputs_processed: nil
625
+ )
626
+ end
627
+
628
+ sig do
629
+ override.returns(
630
+ {
631
+ outputs_below_threshold: Integer,
632
+ outputs_improved: Integer,
633
+ outputs_processed: Integer
634
+ }
635
+ )
636
+ end
637
+ def to_hash
638
+ end
639
+ end
640
+
185
641
  # Status of the selected workflow. May be `inactive` or `active`. Inactive
186
642
  # workflows will not accept events.
187
643
  module Status
@@ -203,6 +659,33 @@ module Deeprails
203
659
  def self.values
204
660
  end
205
661
  end
662
+
663
+ # Type of thresholds used to evaluate the event.
664
+ module ThresholdType
665
+ extend Deeprails::Internal::Type::Enum
666
+
667
+ TaggedSymbol =
668
+ T.type_alias do
669
+ T.all(Symbol, Deeprails::DefendResponse::ThresholdType)
670
+ end
671
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
672
+
673
+ CUSTOM =
674
+ T.let(:custom, Deeprails::DefendResponse::ThresholdType::TaggedSymbol)
675
+ AUTOMATIC =
676
+ T.let(
677
+ :automatic,
678
+ Deeprails::DefendResponse::ThresholdType::TaggedSymbol
679
+ )
680
+
681
+ sig do
682
+ override.returns(
683
+ T::Array[Deeprails::DefendResponse::ThresholdType::TaggedSymbol]
684
+ )
685
+ end
686
+ def self.values
687
+ end
688
+ end
206
689
  end
207
690
  end
208
691
  end