deeprails 0.18.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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +62 -0
  3. data/README.md +1 -1
  4. data/lib/deeprails/internal/stream.rb +29 -0
  5. data/lib/deeprails/internal/transport/base_client.rb +3 -1
  6. data/lib/deeprails/internal/transport/pooled_net_requester.rb +12 -10
  7. data/lib/deeprails/internal/type/base_stream.rb +83 -0
  8. data/lib/deeprails/internal/util.rb +7 -2
  9. data/lib/deeprails/models/defend_create_workflow_params.rb +14 -1
  10. data/lib/deeprails/models/defend_response.rb +134 -10
  11. data/lib/deeprails/models/defend_submit_and_stream_event_params.rb +83 -0
  12. data/lib/deeprails/models/defend_submit_and_stream_event_response.rb +7 -0
  13. data/lib/deeprails/models/defend_submit_event_params.rb +52 -16
  14. data/lib/deeprails/models/defend_update_response.rb +9 -1
  15. data/lib/deeprails/models/defend_update_workflow_params.rb +131 -5
  16. data/lib/deeprails/models/monitor_create_params.rb +14 -1
  17. data/lib/deeprails/models/monitor_detail_response.rb +53 -14
  18. data/lib/deeprails/models/monitor_event_detail_response.rb +6 -2
  19. data/lib/deeprails/models/monitor_submit_event_params.rb +52 -16
  20. data/lib/deeprails/models/monitor_update_params.rb +46 -5
  21. data/lib/deeprails/models/workflow_event_detail_response.rb +88 -16
  22. data/lib/deeprails/models/workflow_event_response.rb +9 -1
  23. data/lib/deeprails/models.rb +2 -0
  24. data/lib/deeprails/resources/defend.rb +67 -4
  25. data/lib/deeprails/resources/monitor.rb +14 -6
  26. data/lib/deeprails/version.rb +1 -1
  27. data/lib/deeprails.rb +5 -0
  28. data/manifest.yaml +1 -0
  29. data/rbi/deeprails/internal/stream.rbi +20 -0
  30. data/rbi/deeprails/internal/transport/base_client.rbi +18 -2
  31. data/rbi/deeprails/internal/type/base_stream.rbi +75 -0
  32. data/rbi/deeprails/models/defend_create_workflow_params.rbi +21 -0
  33. data/rbi/deeprails/models/defend_response.rbi +286 -14
  34. data/rbi/deeprails/models/defend_submit_and_stream_event_params.rbi +148 -0
  35. data/rbi/deeprails/models/defend_submit_and_stream_event_response.rbi +7 -0
  36. data/rbi/deeprails/models/defend_submit_event_params.rbi +108 -25
  37. data/rbi/deeprails/models/defend_update_response.rbi +14 -3
  38. data/rbi/deeprails/models/defend_update_workflow_params.rbi +298 -4
  39. data/rbi/deeprails/models/monitor_create_params.rbi +21 -0
  40. data/rbi/deeprails/models/monitor_detail_response.rbi +103 -22
  41. data/rbi/deeprails/models/monitor_event_detail_response.rbi +4 -2
  42. data/rbi/deeprails/models/monitor_submit_event_params.rbi +108 -25
  43. data/rbi/deeprails/models/monitor_update_params.rbi +107 -4
  44. data/rbi/deeprails/models/workflow_event_detail_response.rbi +170 -24
  45. data/rbi/deeprails/models/workflow_event_response.rbi +8 -0
  46. data/rbi/deeprails/models.rbi +3 -0
  47. data/rbi/deeprails/resources/defend.rbi +96 -6
  48. data/rbi/deeprails/resources/monitor.rbi +28 -8
  49. data/sig/deeprails/internal/stream.rbs +9 -0
  50. data/sig/deeprails/internal/type/base_stream.rbs +38 -0
  51. data/sig/deeprails/models/defend_create_workflow_params.rbs +7 -0
  52. data/sig/deeprails/models/defend_response.rbs +114 -8
  53. data/sig/deeprails/models/defend_submit_and_stream_event_params.rbs +74 -0
  54. data/sig/deeprails/models/defend_submit_and_stream_event_response.rbs +5 -0
  55. data/sig/deeprails/models/defend_submit_event_params.rbs +39 -10
  56. data/sig/deeprails/models/defend_update_response.rbs +10 -3
  57. data/sig/deeprails/models/defend_update_workflow_params.rbs +103 -1
  58. data/sig/deeprails/models/monitor_create_params.rbs +7 -0
  59. data/sig/deeprails/models/monitor_detail_response.rbs +36 -9
  60. data/sig/deeprails/models/monitor_submit_event_params.rbs +39 -10
  61. data/sig/deeprails/models/monitor_update_params.rbs +45 -1
  62. data/sig/deeprails/models/workflow_event_detail_response.rbs +88 -15
  63. data/sig/deeprails/models/workflow_event_response.rbs +5 -0
  64. data/sig/deeprails/models.rbs +2 -0
  65. data/sig/deeprails/resources/defend.rbs +20 -0
  66. data/sig/deeprails/resources/monitor.rbs +4 -0
  67. metadata +28 -2
@@ -11,6 +11,9 @@ module Deeprails
11
11
  )
12
12
  end
13
13
 
14
+ sig { returns(T::Array[String]) }
15
+ attr_accessor :analysis_of_failures
16
+
14
17
  # History of evaluations for the event.
15
18
  sig do
16
19
  returns(
@@ -45,7 +48,12 @@ module Deeprails
45
48
  end
46
49
  attr_accessor :improvement_action
47
50
 
48
- # Status of the improvement tool used to improve the event.
51
+ # Status of the improvement tool used to improve the event. `improvement_required`
52
+ # indicates that the evaluation is complete and the improvement action is needed
53
+ # but is not taking place. `improved` and `improvement_failed` indicate when the
54
+ # improvement action concludes, successfully and unsuccessfully, respectively.
55
+ # `no_improvement_required` means that the first evaluation passed all its
56
+ # metrics!
49
57
  sig do
50
58
  returns(
51
59
  T.nilable(
@@ -55,6 +63,9 @@ module Deeprails
55
63
  end
56
64
  attr_accessor :improvement_tool_status
57
65
 
66
+ sig { returns(T::Array[T.anything]) }
67
+ attr_accessor :key_improvements
68
+
58
69
  # Status of the event.
59
70
  sig do
60
71
  returns(Deeprails::WorkflowEventDetailResponse::Status::TaggedSymbol)
@@ -98,8 +109,8 @@ module Deeprails
98
109
  end
99
110
  attr_writer :automatic_hallucination_tolerance_levels
100
111
 
101
- # Extended AI capabilities available to the event, if any. Can be `web_search`
102
- # and/or `file_search`.
112
+ # Extended AI capabilities available to the event, if any. Can be `web_search`,
113
+ # `file_search`, and/or `context_awareness`.
103
114
  sig do
104
115
  returns(
105
116
  T.nilable(
@@ -145,8 +156,17 @@ module Deeprails
145
156
  end
146
157
  attr_writer :files
147
158
 
159
+ # The maximum number of improvement attempts to be applied to one event before it
160
+ # is considered failed.
161
+ sig { returns(T.nilable(Integer)) }
162
+ attr_reader :max_improvement_attempts
163
+
164
+ sig { params(max_improvement_attempts: Integer).void }
165
+ attr_writer :max_improvement_attempts
166
+
148
167
  sig do
149
168
  params(
169
+ analysis_of_failures: T::Array[String],
150
170
  evaluation_history:
151
171
  T::Array[
152
172
  Deeprails::WorkflowEventDetailResponse::EvaluationHistory::OrHash
@@ -161,6 +181,7 @@ module Deeprails
161
181
  T.nilable(
162
182
  Deeprails::WorkflowEventDetailResponse::ImprovementToolStatus::OrSymbol
163
183
  ),
184
+ key_improvements: T::Array[T.anything],
164
185
  status: Deeprails::WorkflowEventDetailResponse::Status::OrSymbol,
165
186
  threshold_type:
166
187
  Deeprails::WorkflowEventDetailResponse::ThresholdType::OrSymbol,
@@ -175,10 +196,12 @@ module Deeprails
175
196
  Deeprails::WorkflowEventDetailResponse::Capability::OrHash
176
197
  ],
177
198
  custom_hallucination_threshold_values: T::Hash[Symbol, Float],
178
- files: T::Array[Deeprails::WorkflowEventDetailResponse::File::OrHash]
199
+ files: T::Array[Deeprails::WorkflowEventDetailResponse::File::OrHash],
200
+ max_improvement_attempts: Integer
179
201
  ).returns(T.attached_class)
180
202
  end
181
203
  def self.new(
204
+ analysis_of_failures:,
182
205
  # History of evaluations for the event.
183
206
  evaluation_history:,
184
207
  # Evaluation result consisting of average scores and rationales for each of the
@@ -193,8 +216,14 @@ module Deeprails
193
216
  improved_model_output:,
194
217
  # Type of improvement action used to improve the event.
195
218
  improvement_action:,
196
- # Status of the improvement tool used to improve the event.
219
+ # Status of the improvement tool used to improve the event. `improvement_required`
220
+ # indicates that the evaluation is complete and the improvement action is needed
221
+ # but is not taking place. `improved` and `improvement_failed` indicate when the
222
+ # improvement action concludes, successfully and unsuccessfully, respectively.
223
+ # `no_improvement_required` means that the first evaluation passed all its
224
+ # metrics!
197
225
  improvement_tool_status:,
226
+ key_improvements:,
198
227
  # Status of the event.
199
228
  status:,
200
229
  # Type of thresholds used to evaluate the event.
@@ -204,21 +233,25 @@ module Deeprails
204
233
  # Mapping of guardrail metric names to tolerance values. Values are strings
205
234
  # (`low`, `medium`, `high`) representing automatic tolerance levels.
206
235
  automatic_hallucination_tolerance_levels: nil,
207
- # Extended AI capabilities available to the event, if any. Can be `web_search`
208
- # and/or `file_search`.
236
+ # Extended AI capabilities available to the event, if any. Can be `web_search`,
237
+ # `file_search`, and/or `context_awareness`.
209
238
  capabilities: nil,
210
239
  # Mapping of guardrail metric names to threshold values. Values are floating point
211
240
  # numbers (0.0-1.0) representing custom thresholds.
212
241
  custom_hallucination_threshold_values: nil,
213
242
  # List of files available to the event, if any. Will only be present if
214
243
  # `file_search` is enabled.
215
- files: nil
244
+ files: nil,
245
+ # The maximum number of improvement attempts to be applied to one event before it
246
+ # is considered failed.
247
+ max_improvement_attempts: nil
216
248
  )
217
249
  end
218
250
 
219
251
  sig do
220
252
  override.returns(
221
253
  {
254
+ analysis_of_failures: T::Array[String],
222
255
  evaluation_history:
223
256
  T::Array[
224
257
  Deeprails::WorkflowEventDetailResponse::EvaluationHistory
@@ -233,6 +266,7 @@ module Deeprails
233
266
  T.nilable(
234
267
  Deeprails::WorkflowEventDetailResponse::ImprovementToolStatus::TaggedSymbol
235
268
  ),
269
+ key_improvements: T::Array[T.anything],
236
270
  status:
237
271
  Deeprails::WorkflowEventDetailResponse::Status::TaggedSymbol,
238
272
  threshold_type:
@@ -246,7 +280,8 @@ module Deeprails
246
280
  capabilities:
247
281
  T::Array[Deeprails::WorkflowEventDetailResponse::Capability],
248
282
  custom_hallucination_threshold_values: T::Hash[Symbol, Float],
249
- files: T::Array[Deeprails::WorkflowEventDetailResponse::File]
283
+ files: T::Array[Deeprails::WorkflowEventDetailResponse::File],
284
+ max_improvement_attempts: Integer
250
285
  }
251
286
  )
252
287
  end
@@ -262,6 +297,12 @@ module Deeprails
262
297
  )
263
298
  end
264
299
 
300
+ sig { returns(T.nilable(String)) }
301
+ attr_reader :analysis_of_failures
302
+
303
+ sig { params(analysis_of_failures: String).void }
304
+ attr_writer :analysis_of_failures
305
+
265
306
  sig { returns(T.nilable(String)) }
266
307
  attr_reader :attempt
267
308
 
@@ -304,6 +345,29 @@ module Deeprails
304
345
  sig { params(guardrail_metrics: T::Array[String]).void }
305
346
  attr_writer :guardrail_metrics
306
347
 
348
+ sig do
349
+ returns(
350
+ T.nilable(
351
+ Deeprails::WorkflowEventDetailResponse::EvaluationHistory::ImprovementToolStatus::TaggedSymbol
352
+ )
353
+ )
354
+ end
355
+ attr_reader :improvement_tool_status
356
+
357
+ sig do
358
+ params(
359
+ improvement_tool_status:
360
+ Deeprails::WorkflowEventDetailResponse::EvaluationHistory::ImprovementToolStatus::OrSymbol
361
+ ).void
362
+ end
363
+ attr_writer :improvement_tool_status
364
+
365
+ sig { returns(T.nilable(T::Array[String])) }
366
+ attr_reader :key_improvements
367
+
368
+ sig { params(key_improvements: T::Array[String]).void }
369
+ attr_writer :key_improvements
370
+
307
371
  sig { returns(T.nilable(T::Hash[Symbol, T.anything])) }
308
372
  attr_reader :model_input
309
373
 
@@ -316,12 +380,6 @@ module Deeprails
316
380
  sig { params(model_output: String).void }
317
381
  attr_writer :model_output
318
382
 
319
- sig { returns(T.nilable(Time)) }
320
- attr_reader :modified_at
321
-
322
- sig { params(modified_at: Time).void }
323
- attr_writer :modified_at
324
-
325
383
  sig { returns(T.nilable(String)) }
326
384
  attr_reader :nametag
327
385
 
@@ -342,6 +400,7 @@ module Deeprails
342
400
 
343
401
  sig do
344
402
  params(
403
+ analysis_of_failures: String,
345
404
  attempt: String,
346
405
  created_at: Time,
347
406
  error_message: String,
@@ -349,15 +408,18 @@ module Deeprails
349
408
  evaluation_status: String,
350
409
  evaluation_total_cost: Float,
351
410
  guardrail_metrics: T::Array[String],
411
+ improvement_tool_status:
412
+ Deeprails::WorkflowEventDetailResponse::EvaluationHistory::ImprovementToolStatus::OrSymbol,
413
+ key_improvements: T::Array[String],
352
414
  model_input: T::Hash[Symbol, T.anything],
353
415
  model_output: String,
354
- modified_at: Time,
355
416
  nametag: String,
356
417
  progress: Integer,
357
418
  run_mode: String
358
419
  ).returns(T.attached_class)
359
420
  end
360
421
  def self.new(
422
+ analysis_of_failures: nil,
361
423
  attempt: nil,
362
424
  created_at: nil,
363
425
  error_message: nil,
@@ -365,9 +427,10 @@ module Deeprails
365
427
  evaluation_status: nil,
366
428
  evaluation_total_cost: nil,
367
429
  guardrail_metrics: nil,
430
+ improvement_tool_status: nil,
431
+ key_improvements: nil,
368
432
  model_input: nil,
369
433
  model_output: nil,
370
- modified_at: nil,
371
434
  nametag: nil,
372
435
  progress: nil,
373
436
  run_mode: nil
@@ -377,6 +440,7 @@ module Deeprails
377
440
  sig do
378
441
  override.returns(
379
442
  {
443
+ analysis_of_failures: String,
380
444
  attempt: String,
381
445
  created_at: Time,
382
446
  error_message: String,
@@ -384,9 +448,11 @@ module Deeprails
384
448
  evaluation_status: String,
385
449
  evaluation_total_cost: Float,
386
450
  guardrail_metrics: T::Array[String],
451
+ improvement_tool_status:
452
+ Deeprails::WorkflowEventDetailResponse::EvaluationHistory::ImprovementToolStatus::TaggedSymbol,
453
+ key_improvements: T::Array[String],
387
454
  model_input: T::Hash[Symbol, T.anything],
388
455
  model_output: String,
389
- modified_at: Time,
390
456
  nametag: String,
391
457
  progress: Integer,
392
458
  run_mode: String
@@ -395,6 +461,50 @@ module Deeprails
395
461
  end
396
462
  def to_hash
397
463
  end
464
+
465
+ module ImprovementToolStatus
466
+ extend Deeprails::Internal::Type::Enum
467
+
468
+ TaggedSymbol =
469
+ T.type_alias do
470
+ T.all(
471
+ Symbol,
472
+ Deeprails::WorkflowEventDetailResponse::EvaluationHistory::ImprovementToolStatus
473
+ )
474
+ end
475
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
476
+
477
+ IMPROVED =
478
+ T.let(
479
+ :improved,
480
+ Deeprails::WorkflowEventDetailResponse::EvaluationHistory::ImprovementToolStatus::TaggedSymbol
481
+ )
482
+ IMPROVEMENT_FAILED =
483
+ T.let(
484
+ :improvement_failed,
485
+ Deeprails::WorkflowEventDetailResponse::EvaluationHistory::ImprovementToolStatus::TaggedSymbol
486
+ )
487
+ NO_IMPROVEMENT_REQUIRED =
488
+ T.let(
489
+ :no_improvement_required,
490
+ Deeprails::WorkflowEventDetailResponse::EvaluationHistory::ImprovementToolStatus::TaggedSymbol
491
+ )
492
+ IMPROVEMENT_REQUIRED =
493
+ T.let(
494
+ :improvement_required,
495
+ Deeprails::WorkflowEventDetailResponse::EvaluationHistory::ImprovementToolStatus::TaggedSymbol
496
+ )
497
+
498
+ sig do
499
+ override.returns(
500
+ T::Array[
501
+ Deeprails::WorkflowEventDetailResponse::EvaluationHistory::ImprovementToolStatus::TaggedSymbol
502
+ ]
503
+ )
504
+ end
505
+ def self.values
506
+ end
507
+ end
398
508
  end
399
509
 
400
510
  # Type of improvement action used to improve the event.
@@ -437,7 +547,12 @@ module Deeprails
437
547
  end
438
548
  end
439
549
 
440
- # Status of the improvement tool used to improve the event.
550
+ # Status of the improvement tool used to improve the event. `improvement_required`
551
+ # indicates that the evaluation is complete and the improvement action is needed
552
+ # but is not taking place. `improved` and `improvement_failed` indicate when the
553
+ # improvement action concludes, successfully and unsuccessfully, respectively.
554
+ # `no_improvement_required` means that the first evaluation passed all its
555
+ # metrics!
441
556
  module ImprovementToolStatus
442
557
  extend Deeprails::Internal::Type::Enum
443
558
 
@@ -455,9 +570,14 @@ module Deeprails
455
570
  :improved,
456
571
  Deeprails::WorkflowEventDetailResponse::ImprovementToolStatus::TaggedSymbol
457
572
  )
458
- FAILED_ON_MAX_RETRIES =
573
+ IMPROVEMENT_FAILED =
459
574
  T.let(
460
- :"failed on max retries",
575
+ :improvement_failed,
576
+ Deeprails::WorkflowEventDetailResponse::ImprovementToolStatus::TaggedSymbol
577
+ )
578
+ NO_IMPROVEMENT_REQUIRED =
579
+ T.let(
580
+ :no_improvement_required,
461
581
  Deeprails::WorkflowEventDetailResponse::ImprovementToolStatus::TaggedSymbol
462
582
  )
463
583
  IMPROVEMENT_REQUIRED =
@@ -631,19 +751,45 @@ module Deeprails
631
751
  sig { params(file_size: Integer).void }
632
752
  attr_writer :file_size
633
753
 
754
+ sig { returns(T.nilable(String)) }
755
+ attr_reader :presigned_url
756
+
757
+ sig { params(presigned_url: String).void }
758
+ attr_writer :presigned_url
759
+
760
+ sig { returns(T.nilable(Time)) }
761
+ attr_reader :presigned_url_expires_at
762
+
763
+ sig { params(presigned_url_expires_at: Time).void }
764
+ attr_writer :presigned_url_expires_at
765
+
634
766
  sig do
635
767
  params(
636
768
  file_id: String,
637
769
  file_name: String,
638
- file_size: Integer
770
+ file_size: Integer,
771
+ presigned_url: String,
772
+ presigned_url_expires_at: Time
639
773
  ).returns(T.attached_class)
640
774
  end
641
- def self.new(file_id: nil, file_name: nil, file_size: nil)
775
+ def self.new(
776
+ file_id: nil,
777
+ file_name: nil,
778
+ file_size: nil,
779
+ presigned_url: nil,
780
+ presigned_url_expires_at: nil
781
+ )
642
782
  end
643
783
 
644
784
  sig do
645
785
  override.returns(
646
- { file_id: String, file_name: String, file_size: Integer }
786
+ {
787
+ file_id: String,
788
+ file_name: String,
789
+ file_size: Integer,
790
+ presigned_url: String,
791
+ presigned_url_expires_at: Time
792
+ }
647
793
  )
648
794
  end
649
795
  def to_hash
@@ -8,6 +8,10 @@ module Deeprails
8
8
  T.any(Deeprails::WorkflowEventResponse, Deeprails::Internal::AnyHash)
9
9
  end
10
10
 
11
+ # The ID of the billing request for the event.
12
+ sig { returns(String) }
13
+ attr_accessor :billing_request_id
14
+
11
15
  # The time the event was created in UTC.
12
16
  sig { returns(Time) }
13
17
  attr_accessor :created_at
@@ -26,6 +30,7 @@ module Deeprails
26
30
 
27
31
  sig do
28
32
  params(
33
+ billing_request_id: String,
29
34
  created_at: Time,
30
35
  event_id: String,
31
36
  status: Deeprails::WorkflowEventResponse::Status::OrSymbol,
@@ -33,6 +38,8 @@ module Deeprails
33
38
  ).returns(T.attached_class)
34
39
  end
35
40
  def self.new(
41
+ # The ID of the billing request for the event.
42
+ billing_request_id:,
36
43
  # The time the event was created in UTC.
37
44
  created_at:,
38
45
  # A unique workflow event ID.
@@ -47,6 +54,7 @@ module Deeprails
47
54
  sig do
48
55
  override.returns(
49
56
  {
57
+ billing_request_id: String,
50
58
  created_at: Time,
51
59
  event_id: String,
52
60
  status: Deeprails::WorkflowEventResponse::Status::TaggedSymbol,
@@ -11,6 +11,9 @@ module Deeprails
11
11
 
12
12
  DefendRetrieveWorkflowParams = Deeprails::Models::DefendRetrieveWorkflowParams
13
13
 
14
+ DefendSubmitAndStreamEventParams =
15
+ Deeprails::Models::DefendSubmitAndStreamEventParams
16
+
14
17
  DefendSubmitEventParams = Deeprails::Models::DefendSubmitEventParams
15
18
 
16
19
  DefendUpdateResponse = Deeprails::Models::DefendUpdateResponse
@@ -17,6 +17,7 @@ module Deeprails
17
17
  Symbol,
18
18
  Deeprails::DefendCreateWorkflowParams::AutomaticHallucinationToleranceLevel::OrSymbol
19
19
  ],
20
+ context_awareness: T::Boolean,
20
21
  custom_hallucination_threshold_values: T::Hash[Symbol, Float],
21
22
  description: String,
22
23
  file_search: T::Array[String],
@@ -45,6 +46,13 @@ module Deeprails
45
46
  # `instruction_adherence`, `context_adherence`, `ground_truth_adherence`, or
46
47
  # `comprehensive_safety`.
47
48
  automatic_hallucination_tolerance_levels: nil,
49
+ # Context includes any structured information that directly relates to the model’s
50
+ # input and expected output—e.g., the recent turn-by-turn history between an AI
51
+ # tutor and a student, facts or state passed through an agentic workflow, or other
52
+ # domain-specific signals your system already knows and wants the model to
53
+ # condition on. This field determines whether to enable context awareness for this
54
+ # workflow's evaluations. Defaults to false.
55
+ context_awareness: nil,
48
56
  # Mapping of guardrail metrics to floating point threshold values. Possible
49
57
  # metrics are `correctness`, `completeness`, `instruction_adherence`,
50
58
  # `context_adherence`, `ground_truth_adherence`, or `comprehensive_safety`.
@@ -98,6 +106,42 @@ module Deeprails
98
106
  )
99
107
  end
100
108
 
109
+ # Use this endpoint to create a new event for a guardrail workflow with real-time
110
+ # streaming feedback via Server-Sent Events (SSE).
111
+ sig do
112
+ params(
113
+ workflow_id: String,
114
+ model_input: T::Hash[Symbol, T.anything],
115
+ model_output: String,
116
+ model_used: String,
117
+ run_mode:
118
+ Deeprails::DefendSubmitAndStreamEventParams::RunMode::OrSymbol,
119
+ stream: T::Boolean,
120
+ nametag: String,
121
+ request_options: Deeprails::RequestOptions::OrHash
122
+ ).returns(Deeprails::Internal::Stream[String])
123
+ end
124
+ def submit_and_stream_event_streaming(
125
+ # Path param: The ID of the workflow to create the event for.
126
+ workflow_id,
127
+ # Body param: The input provided to the model (e.g., prompt, messages).
128
+ model_input:,
129
+ # Body param: The output generated by the model to be evaluated.
130
+ model_output:,
131
+ # Body param: The model that generated the output (e.g., "gpt-4", "claude-3").
132
+ model_used:,
133
+ # Body param: The evaluation run mode. Streaming only supports fast, precision,
134
+ # and precision_codex.
135
+ run_mode:,
136
+ # Query param: Enable SSE streaming for real-time token feedback. Only supported
137
+ # for single-model run modes (fast, precision, precision_codex).
138
+ stream: nil,
139
+ # Body param: Optional tag to identify this event.
140
+ nametag: nil,
141
+ request_options: {}
142
+ )
143
+ end
144
+
101
145
  # Use this endpoint to submit a model input and output pair to a workflow for
102
146
  # evaluation
103
147
  sig do
@@ -115,8 +159,8 @@ module Deeprails
115
159
  # Workflow ID associated with this event.
116
160
  workflow_id,
117
161
  # A dictionary of inputs sent to the LLM to generate output. The dictionary must
118
- # contain at least a `user_prompt` field or a `system_prompt` field. For the
119
- # ground_truth_adherence guardrail metric, `ground_truth` should be provided.
162
+ # contain a `user_prompt` field. For the ground_truth_adherence guardrail metric,
163
+ # `ground_truth` should be provided.
120
164
  model_input:,
121
165
  # Output generated by the LLM to be evaluated.
122
166
  model_output:,
@@ -124,8 +168,8 @@ module Deeprails
124
168
  model_used:,
125
169
  # Run mode for the workflow event. The run mode allows the user to optimize for
126
170
  # speed, accuracy, and cost by determining which models are used to evaluate the
127
- # event. Available run modes include `precision_plus`, `precision`, `smart`, and
128
- # `economy`. Defaults to `smart`.
171
+ # event. Available run modes include `precision_plus_codex`, `precision_plus`,
172
+ # `precision`, `smart`, and `economy`. Defaults to `smart`.
129
173
  run_mode:,
130
174
  # An optional, user-defined tag for the event.
131
175
  nametag: nil,
@@ -137,18 +181,64 @@ module Deeprails
137
181
  sig do
138
182
  params(
139
183
  workflow_id: String,
184
+ automatic_hallucination_tolerance_levels:
185
+ T::Hash[
186
+ Symbol,
187
+ Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::OrSymbol
188
+ ],
189
+ context_awareness: T::Boolean,
190
+ custom_hallucination_threshold_values: T::Hash[Symbol, Float],
140
191
  description: String,
192
+ file_search: T::Array[String],
193
+ improvement_action:
194
+ Deeprails::DefendUpdateWorkflowParams::ImprovementAction::OrSymbol,
195
+ max_improvement_attempts: Integer,
141
196
  name: String,
197
+ threshold_type:
198
+ Deeprails::DefendUpdateWorkflowParams::ThresholdType::OrSymbol,
199
+ web_search: T::Boolean,
142
200
  request_options: Deeprails::RequestOptions::OrHash
143
201
  ).returns(Deeprails::DefendUpdateResponse)
144
202
  end
145
203
  def update_workflow(
146
204
  # The ID of the workflow to edit.
147
205
  workflow_id,
148
- # Description for the workflow.
206
+ # New mapping of guardrail metrics to hallucination tolerance levels (either
207
+ # `low`, `medium`, or `high`) to be used when `threshold_type` is set to
208
+ # `automatic`. Possible metrics are `completeness`, `instruction_adherence`,
209
+ # `context_adherence`, `ground_truth_adherence`, or `comprehensive_safety`.
210
+ automatic_hallucination_tolerance_levels: nil,
211
+ # Whether to enable context awareness for this workflow's evaluations.
212
+ context_awareness: nil,
213
+ # New mapping of guardrail metrics to floating point threshold values to be used
214
+ # when `threshold_type` is set to `custom`. Possible metrics are `correctness`,
215
+ # `completeness`, `instruction_adherence`, `context_adherence`,
216
+ # `ground_truth_adherence`, or `comprehensive_safety`.
217
+ custom_hallucination_threshold_values: nil,
218
+ # New description for the workflow.
149
219
  description: nil,
150
- # Name of the workflow.
220
+ # An array of file IDs to search in the workflow's evaluations. Files must be
221
+ # uploaded via the DeepRails API first.
222
+ file_search: nil,
223
+ # The new action used to improve outputs that fail one or more guardrail metrics
224
+ # for the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs
225
+ # the user's input prompt with minor induced variance. FixIt attempts to directly
226
+ # address the shortcomings of the output using the guardrail failure rationale. Do
227
+ # Nothing does not attempt any improvement.
228
+ improvement_action: nil,
229
+ # Max. number of improvement action attempts until a given event passes the
230
+ # guardrails. Defaults to 10.
231
+ max_improvement_attempts: nil,
232
+ # New name for the workflow.
151
233
  name: nil,
234
+ # New type of thresholds to use for the workflow, either `automatic` or `custom`.
235
+ # Automatic thresholds are assigned internally after the user specifies a
236
+ # qualitative tolerance for the metrics, whereas custom metrics allow the user to
237
+ # set the threshold for each metric as a floating point number between 0.0 and
238
+ # 1.0.
239
+ threshold_type: nil,
240
+ # Whether to enable web search for this workflow's evaluations.
241
+ web_search: nil,
152
242
  request_options: {}
153
243
  )
154
244
  end
@@ -10,6 +10,7 @@ module Deeprails
10
10
  guardrail_metrics:
11
11
  T::Array[Deeprails::MonitorCreateParams::GuardrailMetric::OrSymbol],
12
12
  name: String,
13
+ context_awareness: T::Boolean,
13
14
  description: String,
14
15
  file_search: T::Array[String],
15
16
  web_search: T::Boolean,
@@ -24,6 +25,13 @@ module Deeprails
24
25
  guardrail_metrics:,
25
26
  # Name of the new monitor.
26
27
  name:,
28
+ # Context includes any structured information that directly relates to the model’s
29
+ # input and expected output—e.g., the recent turn-by-turn history between an AI
30
+ # tutor and a student, facts or state passed through an agentic workflow, or other
31
+ # domain-specific signals your system already knows and wants the model to
32
+ # condition on. This field determines whether to enable context awareness for this
33
+ # monitor's evaluations. Defaults to false.
34
+ context_awareness: nil,
27
35
  # Description of the new monitor.
28
36
  description: nil,
29
37
  # An array of file IDs to search in the monitor's evaluations. Files must be
@@ -54,27 +62,39 @@ module Deeprails
54
62
  )
55
63
  end
56
64
 
57
- # Use this endpoint to update the name, description, or status of an existing
58
- # monitor
65
+ # Use this endpoint to update the name, status, and/or other details of an
66
+ # existing monitor.
59
67
  sig do
60
68
  params(
61
69
  monitor_id: String,
62
70
  description: String,
71
+ file_search: T::Array[String],
72
+ guardrail_metrics:
73
+ T::Array[Deeprails::MonitorUpdateParams::GuardrailMetric::OrSymbol],
63
74
  name: String,
64
75
  status: Deeprails::MonitorUpdateParams::Status::OrSymbol,
76
+ web_search: T::Boolean,
65
77
  request_options: Deeprails::RequestOptions::OrHash
66
78
  ).returns(Deeprails::MonitorUpdateResponse)
67
79
  end
68
80
  def update(
69
81
  # The ID of the monitor to edit.
70
82
  monitor_id,
71
- # Description of the monitor.
83
+ # New description of the monitor.
72
84
  description: nil,
73
- # Name of the monitor.
85
+ # An array of file IDs to search in the monitor's evaluations. Files must be
86
+ # uploaded via the DeepRails API first.
87
+ file_search: nil,
88
+ # An array of the new guardrail metrics that model input and output pairs will be
89
+ # evaluated on.
90
+ guardrail_metrics: nil,
91
+ # New name of the monitor.
74
92
  name: nil,
75
93
  # Status of the monitor. Can be `active` or `inactive`. Inactive monitors no
76
94
  # longer record and evaluate events.
77
95
  status: nil,
96
+ # Whether to enable web search for this monitor's evaluations.
97
+ web_search: nil,
78
98
  request_options: {}
79
99
  )
80
100
  end
@@ -112,8 +132,8 @@ module Deeprails
112
132
  # The ID of the monitor associated with this event.
113
133
  monitor_id,
114
134
  # A dictionary of inputs sent to the LLM to generate output. The dictionary must
115
- # contain at least a `user_prompt` field or a `system_prompt` field. For
116
- # ground_truth_adherence guardrail metric, `ground_truth` should be provided.
135
+ # contain a `user_prompt` field. For ground_truth_adherence guardrail metric,
136
+ # `ground_truth` should be provided.
117
137
  model_input:,
118
138
  # Output generated by the LLM to be evaluated.
119
139
  model_output:,
@@ -121,8 +141,8 @@ module Deeprails
121
141
  nametag: nil,
122
142
  # Run mode for the monitor event. The run mode allows the user to optimize for
123
143
  # speed, accuracy, and cost by determining which models are used to evaluate the
124
- # event. Available run modes include `precision_plus`, `precision`, `smart`, and
125
- # `economy`. Defaults to `smart`.
144
+ # event. Available run modes include `precision_plus_codex`, `precision_plus`,
145
+ # `precision`, `smart`, and `economy`. Defaults to `smart`.
126
146
  run_mode: nil,
127
147
  request_options: {}
128
148
  )
@@ -0,0 +1,9 @@
1
+ module Deeprails
2
+ module Internal
3
+ class Stream[Elem]
4
+ include Deeprails::Internal::Type::BaseStream[Deeprails::Internal::Util::server_sent_event, Elem]
5
+
6
+ private def iterator: -> Enumerable[Elem]
7
+ end
8
+ end
9
+ end