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
@@ -15,8 +15,8 @@ module Deeprails
15
15
  end
16
16
 
17
17
  # A dictionary of inputs sent to the LLM to generate output. The dictionary must
18
- # contain at least a `user_prompt` field or a `system_prompt` field. For the
19
- # ground_truth_adherence guardrail metric, `ground_truth` should be provided.
18
+ # contain a `user_prompt` field. For the ground_truth_adherence guardrail metric,
19
+ # `ground_truth` should be provided.
20
20
  sig { returns(Deeprails::DefendSubmitEventParams::ModelInput) }
21
21
  attr_reader :model_input
22
22
 
@@ -37,8 +37,8 @@ module Deeprails
37
37
 
38
38
  # Run mode for the workflow event. The run mode allows the user to optimize for
39
39
  # speed, accuracy, and cost by determining which models are used to evaluate the
40
- # event. Available run modes include `precision_plus`, `precision`, `smart`, and
41
- # `economy`. Defaults to `smart`.
40
+ # event. Available run modes include `precision_plus_codex`, `precision_plus`,
41
+ # `precision`, `smart`, and `economy`. Defaults to `smart`.
42
42
  sig { returns(Deeprails::DefendSubmitEventParams::RunMode::OrSymbol) }
43
43
  attr_accessor :run_mode
44
44
 
@@ -61,8 +61,8 @@ module Deeprails
61
61
  end
62
62
  def self.new(
63
63
  # A dictionary of inputs sent to the LLM to generate output. The dictionary must
64
- # contain at least a `user_prompt` field or a `system_prompt` field. For the
65
- # ground_truth_adherence guardrail metric, `ground_truth` should be provided.
64
+ # contain a `user_prompt` field. For the ground_truth_adherence guardrail metric,
65
+ # `ground_truth` should be provided.
66
66
  model_input:,
67
67
  # Output generated by the LLM to be evaluated.
68
68
  model_output:,
@@ -70,8 +70,8 @@ module Deeprails
70
70
  model_used:,
71
71
  # Run mode for the workflow event. The run mode allows the user to optimize for
72
72
  # speed, accuracy, and cost by determining which models are used to evaluate the
73
- # event. Available run modes include `precision_plus`, `precision`, `smart`, and
74
- # `economy`. Defaults to `smart`.
73
+ # event. Available run modes include `precision_plus_codex`, `precision_plus`,
74
+ # `precision`, `smart`, and `economy`. Defaults to `smart`.
75
75
  run_mode:,
76
76
  # An optional, user-defined tag for the event.
77
77
  nametag: nil,
@@ -103,6 +103,34 @@ module Deeprails
103
103
  )
104
104
  end
105
105
 
106
+ # The user prompt used to generate the output.
107
+ sig { returns(String) }
108
+ attr_accessor :user_prompt
109
+
110
+ # Any structured information that directly relates to the model’s input and
111
+ # expected output—e.g., the recent turn-by-turn history between an AI tutor and a
112
+ # student, facts or state passed through an agentic workflow, or other
113
+ # domain-specific signals your system already knows and wants the model to
114
+ # condition on.
115
+ sig do
116
+ returns(
117
+ T.nilable(
118
+ T::Array[Deeprails::DefendSubmitEventParams::ModelInput::Context]
119
+ )
120
+ )
121
+ end
122
+ attr_reader :context
123
+
124
+ sig do
125
+ params(
126
+ context:
127
+ T::Array[
128
+ Deeprails::DefendSubmitEventParams::ModelInput::Context::OrHash
129
+ ]
130
+ ).void
131
+ end
132
+ attr_writer :context
133
+
106
134
  # The ground truth for evaluating the Ground Truth Adherence guardrail.
107
135
  sig { returns(T.nilable(String)) }
108
136
  attr_reader :ground_truth
@@ -117,46 +145,96 @@ module Deeprails
117
145
  sig { params(system_prompt: String).void }
118
146
  attr_writer :system_prompt
119
147
 
120
- # The user prompt used to generate the output.
121
- sig { returns(T.nilable(String)) }
122
- attr_reader :user_prompt
123
-
124
- sig { params(user_prompt: String).void }
125
- attr_writer :user_prompt
126
-
127
148
  # A dictionary of inputs sent to the LLM to generate output. The dictionary must
128
- # contain at least a `user_prompt` field or a `system_prompt` field. For the
129
- # ground_truth_adherence guardrail metric, `ground_truth` should be provided.
149
+ # contain a `user_prompt` field. For the ground_truth_adherence guardrail metric,
150
+ # `ground_truth` should be provided.
130
151
  sig do
131
152
  params(
153
+ user_prompt: String,
154
+ context:
155
+ T::Array[
156
+ Deeprails::DefendSubmitEventParams::ModelInput::Context::OrHash
157
+ ],
132
158
  ground_truth: String,
133
- system_prompt: String,
134
- user_prompt: String
159
+ system_prompt: String
135
160
  ).returns(T.attached_class)
136
161
  end
137
162
  def self.new(
163
+ # The user prompt used to generate the output.
164
+ user_prompt:,
165
+ # Any structured information that directly relates to the model’s input and
166
+ # expected output—e.g., the recent turn-by-turn history between an AI tutor and a
167
+ # student, facts or state passed through an agentic workflow, or other
168
+ # domain-specific signals your system already knows and wants the model to
169
+ # condition on.
170
+ context: nil,
138
171
  # The ground truth for evaluating the Ground Truth Adherence guardrail.
139
172
  ground_truth: nil,
140
173
  # The system prompt used to generate the output.
141
- system_prompt: nil,
142
- # The user prompt used to generate the output.
143
- user_prompt: nil
174
+ system_prompt: nil
144
175
  )
145
176
  end
146
177
 
147
178
  sig do
148
179
  override.returns(
149
- { ground_truth: String, system_prompt: String, user_prompt: String }
180
+ {
181
+ user_prompt: String,
182
+ context:
183
+ T::Array[
184
+ Deeprails::DefendSubmitEventParams::ModelInput::Context
185
+ ],
186
+ ground_truth: String,
187
+ system_prompt: String
188
+ }
150
189
  )
151
190
  end
152
191
  def to_hash
153
192
  end
193
+
194
+ class Context < Deeprails::Internal::Type::BaseModel
195
+ OrHash =
196
+ T.type_alias do
197
+ T.any(
198
+ Deeprails::DefendSubmitEventParams::ModelInput::Context,
199
+ Deeprails::Internal::AnyHash
200
+ )
201
+ end
202
+
203
+ # The content of the message.
204
+ sig { returns(T.nilable(String)) }
205
+ attr_reader :content
206
+
207
+ sig { params(content: String).void }
208
+ attr_writer :content
209
+
210
+ # The role of the speaker.
211
+ sig { returns(T.nilable(String)) }
212
+ attr_reader :role
213
+
214
+ sig { params(role: String).void }
215
+ attr_writer :role
216
+
217
+ sig do
218
+ params(content: String, role: String).returns(T.attached_class)
219
+ end
220
+ def self.new(
221
+ # The content of the message.
222
+ content: nil,
223
+ # The role of the speaker.
224
+ role: nil
225
+ )
226
+ end
227
+
228
+ sig { override.returns({ content: String, role: String }) }
229
+ def to_hash
230
+ end
231
+ end
154
232
  end
155
233
 
156
234
  # Run mode for the workflow event. The run mode allows the user to optimize for
157
235
  # speed, accuracy, and cost by determining which models are used to evaluate the
158
- # event. Available run modes include `precision_plus`, `precision`, `smart`, and
159
- # `economy`. Defaults to `smart`.
236
+ # event. Available run modes include `precision_plus_codex`, `precision_plus`,
237
+ # `precision`, `smart`, and `economy`. Defaults to `smart`.
160
238
  module RunMode
161
239
  extend Deeprails::Internal::Type::Enum
162
240
 
@@ -166,6 +244,11 @@ module Deeprails
166
244
  end
167
245
  OrSymbol = T.type_alias { T.any(Symbol, String) }
168
246
 
247
+ PRECISION_PLUS_CODEX =
248
+ T.let(
249
+ :precision_plus_codex,
250
+ Deeprails::DefendSubmitEventParams::RunMode::TaggedSymbol
251
+ )
169
252
  PRECISION_PLUS =
170
253
  T.let(
171
254
  :precision_plus,
@@ -21,11 +21,19 @@ module Deeprails
21
21
  sig { returns(String) }
22
22
  attr_accessor :workflow_id
23
23
 
24
+ # The name of the workflow.
25
+ sig { returns(T.nilable(String)) }
26
+ attr_reader :name
27
+
28
+ sig { params(name: String).void }
29
+ attr_writer :name
30
+
24
31
  sig do
25
32
  params(
26
33
  modified_at: Time,
27
34
  status: Deeprails::DefendUpdateResponse::Status::OrSymbol,
28
- workflow_id: String
35
+ workflow_id: String,
36
+ name: String
29
37
  ).returns(T.attached_class)
30
38
  end
31
39
  def self.new(
@@ -35,7 +43,9 @@ module Deeprails
35
43
  # workflows will not accept events.
36
44
  status:,
37
45
  # A unique workflow ID.
38
- workflow_id:
46
+ workflow_id:,
47
+ # The name of the workflow.
48
+ name: nil
39
49
  )
40
50
  end
41
51
 
@@ -44,7 +54,8 @@ module Deeprails
44
54
  {
45
55
  modified_at: Time,
46
56
  status: Deeprails::DefendUpdateResponse::Status::TaggedSymbol,
47
- workflow_id: String
57
+ workflow_id: String,
58
+ name: String
48
59
  }
49
60
  )
50
61
  end
@@ -14,32 +14,193 @@ module Deeprails
14
14
  )
15
15
  end
16
16
 
17
- # Description for the workflow.
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
- # Name of the workflow.
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
- # Description for the workflow.
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
- # Name of the workflow.
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
@@ -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,