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