deeprails 0.18.0 → 0.24.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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +92 -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 +13 -11
  7. data/lib/deeprails/internal/type/base_stream.rb +83 -0
  8. data/lib/deeprails/internal/util.rb +39 -3
  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_retrieve_event_params.rb +7 -1
  12. data/lib/deeprails/models/defend_retrieve_workflow_params.rb +8 -1
  13. data/lib/deeprails/models/defend_submit_and_stream_event_params.rb +92 -0
  14. data/lib/deeprails/models/defend_submit_and_stream_event_response.rb +7 -0
  15. data/lib/deeprails/models/defend_submit_event_params.rb +70 -20
  16. data/lib/deeprails/models/defend_update_response.rb +9 -1
  17. data/lib/deeprails/models/defend_update_workflow_params.rb +138 -5
  18. data/lib/deeprails/models/monitor_create_params.rb +14 -1
  19. data/lib/deeprails/models/monitor_detail_response.rb +60 -17
  20. data/lib/deeprails/models/monitor_event_detail_response.rb +11 -5
  21. data/lib/deeprails/models/monitor_retrieve_event_params.rb +7 -1
  22. data/lib/deeprails/models/monitor_retrieve_params.rb +8 -1
  23. data/lib/deeprails/models/monitor_submit_event_params.rb +70 -20
  24. data/lib/deeprails/models/monitor_update_params.rb +53 -5
  25. data/lib/deeprails/models/workflow_event_detail_response.rb +99 -16
  26. data/lib/deeprails/models/workflow_event_response.rb +9 -1
  27. data/lib/deeprails/models.rb +2 -0
  28. data/lib/deeprails/resources/defend.rb +70 -5
  29. data/lib/deeprails/resources/monitor.rb +16 -7
  30. data/lib/deeprails/version.rb +1 -1
  31. data/lib/deeprails.rb +5 -0
  32. data/manifest.yaml +1 -0
  33. data/rbi/deeprails/internal/stream.rbi +20 -0
  34. data/rbi/deeprails/internal/transport/base_client.rbi +18 -2
  35. data/rbi/deeprails/internal/type/base_stream.rbi +75 -0
  36. data/rbi/deeprails/internal/util.rbi +21 -1
  37. data/rbi/deeprails/models/defend_create_workflow_params.rbi +21 -0
  38. data/rbi/deeprails/models/defend_response.rbi +286 -14
  39. data/rbi/deeprails/models/defend_retrieve_event_params.rbi +10 -2
  40. data/rbi/deeprails/models/defend_retrieve_workflow_params.rbi +10 -1
  41. data/rbi/deeprails/models/defend_submit_and_stream_event_params.rbi +155 -0
  42. data/rbi/deeprails/models/defend_submit_and_stream_event_response.rbi +7 -0
  43. data/rbi/deeprails/models/defend_submit_event_params.rbi +134 -31
  44. data/rbi/deeprails/models/defend_update_response.rbi +14 -3
  45. data/rbi/deeprails/models/defend_update_workflow_params.rbi +304 -4
  46. data/rbi/deeprails/models/monitor_create_params.rbi +21 -0
  47. data/rbi/deeprails/models/monitor_detail_response.rbi +122 -28
  48. data/rbi/deeprails/models/monitor_event_detail_response.rbi +20 -8
  49. data/rbi/deeprails/models/monitor_retrieve_event_params.rbi +10 -2
  50. data/rbi/deeprails/models/monitor_retrieve_params.rbi +10 -1
  51. data/rbi/deeprails/models/monitor_submit_event_params.rbi +134 -31
  52. data/rbi/deeprails/models/monitor_update_params.rbi +113 -4
  53. data/rbi/deeprails/models/workflow_event_detail_response.rbi +204 -24
  54. data/rbi/deeprails/models/workflow_event_response.rbi +8 -0
  55. data/rbi/deeprails/models.rbi +3 -0
  56. data/rbi/deeprails/resources/defend.rbi +101 -6
  57. data/rbi/deeprails/resources/monitor.rbi +31 -8
  58. data/sig/deeprails/internal/stream.rbs +9 -0
  59. data/sig/deeprails/internal/type/base_stream.rbs +38 -0
  60. data/sig/deeprails/internal/util.rbs +10 -0
  61. data/sig/deeprails/models/defend_create_workflow_params.rbs +7 -0
  62. data/sig/deeprails/models/defend_response.rbs +114 -8
  63. data/sig/deeprails/models/defend_retrieve_event_params.rbs +6 -1
  64. data/sig/deeprails/models/defend_retrieve_workflow_params.rbs +6 -1
  65. data/sig/deeprails/models/defend_submit_and_stream_event_params.rbs +73 -0
  66. data/sig/deeprails/models/defend_submit_and_stream_event_response.rbs +5 -0
  67. data/sig/deeprails/models/defend_submit_event_params.rbs +53 -13
  68. data/sig/deeprails/models/defend_update_response.rbs +10 -3
  69. data/sig/deeprails/models/defend_update_workflow_params.rbs +108 -1
  70. data/sig/deeprails/models/monitor_create_params.rbs +7 -0
  71. data/sig/deeprails/models/monitor_detail_response.rbs +48 -13
  72. data/sig/deeprails/models/monitor_event_detail_response.rbs +12 -4
  73. data/sig/deeprails/models/monitor_retrieve_event_params.rbs +6 -1
  74. data/sig/deeprails/models/monitor_retrieve_params.rbs +6 -1
  75. data/sig/deeprails/models/monitor_submit_event_params.rbs +53 -13
  76. data/sig/deeprails/models/monitor_update_params.rbs +50 -1
  77. data/sig/deeprails/models/workflow_event_detail_response.rbs +100 -15
  78. data/sig/deeprails/models/workflow_event_response.rbs +5 -0
  79. data/sig/deeprails/models.rbs +2 -0
  80. data/sig/deeprails/resources/defend.rbs +20 -0
  81. data/sig/deeprails/resources/monitor.rbs +4 -0
  82. metadata +28 -2
@@ -14,9 +14,12 @@ module Deeprails
14
14
  )
15
15
  end
16
16
 
17
+ sig { returns(String) }
18
+ attr_accessor :workflow_id
19
+
17
20
  # 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.
21
+ # contain a `user_prompt` field. For the ground_truth_adherence guardrail metric,
22
+ # `ground_truth` should be provided.
20
23
  sig { returns(Deeprails::DefendSubmitEventParams::ModelInput) }
21
24
  attr_reader :model_input
22
25
 
@@ -37,8 +40,11 @@ module Deeprails
37
40
 
38
41
  # Run mode for the workflow event. The run mode allows the user to optimize for
39
42
  # 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`.
43
+ # event. Available run modes (fastest to most thorough): `super_fast`, `fast`,
44
+ # `precision`, `precision_codex`, `precision_max`, and `precision_max_codex`.
45
+ # Defaults to `fast`. Note: `super_fast` does not support Web Search or File
46
+ # Search — if your workflow has these capabilities enabled, use a different run
47
+ # mode or edit the workflow to disable them.
42
48
  sig { returns(Deeprails::DefendSubmitEventParams::RunMode::OrSymbol) }
43
49
  attr_accessor :run_mode
44
50
 
@@ -51,6 +57,7 @@ module Deeprails
51
57
 
52
58
  sig do
53
59
  params(
60
+ workflow_id: String,
54
61
  model_input: Deeprails::DefendSubmitEventParams::ModelInput::OrHash,
55
62
  model_output: String,
56
63
  model_used: String,
@@ -60,9 +67,10 @@ module Deeprails
60
67
  ).returns(T.attached_class)
61
68
  end
62
69
  def self.new(
70
+ workflow_id:,
63
71
  # 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.
72
+ # contain a `user_prompt` field. For the ground_truth_adherence guardrail metric,
73
+ # `ground_truth` should be provided.
66
74
  model_input:,
67
75
  # Output generated by the LLM to be evaluated.
68
76
  model_output:,
@@ -70,8 +78,11 @@ module Deeprails
70
78
  model_used:,
71
79
  # Run mode for the workflow event. The run mode allows the user to optimize for
72
80
  # 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`.
81
+ # event. Available run modes (fastest to most thorough): `super_fast`, `fast`,
82
+ # `precision`, `precision_codex`, `precision_max`, and `precision_max_codex`.
83
+ # Defaults to `fast`. Note: `super_fast` does not support Web Search or File
84
+ # Search — if your workflow has these capabilities enabled, use a different run
85
+ # mode or edit the workflow to disable them.
75
86
  run_mode:,
76
87
  # An optional, user-defined tag for the event.
77
88
  nametag: nil,
@@ -82,6 +93,7 @@ module Deeprails
82
93
  sig do
83
94
  override.returns(
84
95
  {
96
+ workflow_id: String,
85
97
  model_input: Deeprails::DefendSubmitEventParams::ModelInput,
86
98
  model_output: String,
87
99
  model_used: String,
@@ -103,6 +115,34 @@ module Deeprails
103
115
  )
104
116
  end
105
117
 
118
+ # The user prompt used to generate the output.
119
+ sig { returns(String) }
120
+ attr_accessor :user_prompt
121
+
122
+ # Any structured information that directly relates to the model’s input and
123
+ # expected output—e.g., the recent turn-by-turn history between an AI tutor and a
124
+ # student, facts or state passed through an agentic workflow, or other
125
+ # domain-specific signals your system already knows and wants the model to
126
+ # condition on.
127
+ sig do
128
+ returns(
129
+ T.nilable(
130
+ T::Array[Deeprails::DefendSubmitEventParams::ModelInput::Context]
131
+ )
132
+ )
133
+ end
134
+ attr_reader :context
135
+
136
+ sig do
137
+ params(
138
+ context:
139
+ T::Array[
140
+ Deeprails::DefendSubmitEventParams::ModelInput::Context::OrHash
141
+ ]
142
+ ).void
143
+ end
144
+ attr_writer :context
145
+
106
146
  # The ground truth for evaluating the Ground Truth Adherence guardrail.
107
147
  sig { returns(T.nilable(String)) }
108
148
  attr_reader :ground_truth
@@ -117,46 +157,99 @@ module Deeprails
117
157
  sig { params(system_prompt: String).void }
118
158
  attr_writer :system_prompt
119
159
 
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
160
  # 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.
161
+ # contain a `user_prompt` field. For the ground_truth_adherence guardrail metric,
162
+ # `ground_truth` should be provided.
130
163
  sig do
131
164
  params(
165
+ user_prompt: String,
166
+ context:
167
+ T::Array[
168
+ Deeprails::DefendSubmitEventParams::ModelInput::Context::OrHash
169
+ ],
132
170
  ground_truth: String,
133
- system_prompt: String,
134
- user_prompt: String
171
+ system_prompt: String
135
172
  ).returns(T.attached_class)
136
173
  end
137
174
  def self.new(
175
+ # The user prompt used to generate the output.
176
+ user_prompt:,
177
+ # Any structured information that directly relates to the model’s input and
178
+ # expected output—e.g., the recent turn-by-turn history between an AI tutor and a
179
+ # student, facts or state passed through an agentic workflow, or other
180
+ # domain-specific signals your system already knows and wants the model to
181
+ # condition on.
182
+ context: nil,
138
183
  # The ground truth for evaluating the Ground Truth Adherence guardrail.
139
184
  ground_truth: nil,
140
185
  # 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
186
+ system_prompt: nil
144
187
  )
145
188
  end
146
189
 
147
190
  sig do
148
191
  override.returns(
149
- { ground_truth: String, system_prompt: String, user_prompt: String }
192
+ {
193
+ user_prompt: String,
194
+ context:
195
+ T::Array[
196
+ Deeprails::DefendSubmitEventParams::ModelInput::Context
197
+ ],
198
+ ground_truth: String,
199
+ system_prompt: String
200
+ }
150
201
  )
151
202
  end
152
203
  def to_hash
153
204
  end
205
+
206
+ class Context < Deeprails::Internal::Type::BaseModel
207
+ OrHash =
208
+ T.type_alias do
209
+ T.any(
210
+ Deeprails::DefendSubmitEventParams::ModelInput::Context,
211
+ Deeprails::Internal::AnyHash
212
+ )
213
+ end
214
+
215
+ # The content of the message.
216
+ sig { returns(T.nilable(String)) }
217
+ attr_reader :content
218
+
219
+ sig { params(content: String).void }
220
+ attr_writer :content
221
+
222
+ # The role of the speaker.
223
+ sig { returns(T.nilable(String)) }
224
+ attr_reader :role
225
+
226
+ sig { params(role: String).void }
227
+ attr_writer :role
228
+
229
+ sig do
230
+ params(content: String, role: String).returns(T.attached_class)
231
+ end
232
+ def self.new(
233
+ # The content of the message.
234
+ content: nil,
235
+ # The role of the speaker.
236
+ role: nil
237
+ )
238
+ end
239
+
240
+ sig { override.returns({ content: String, role: String }) }
241
+ def to_hash
242
+ end
243
+ end
154
244
  end
155
245
 
156
246
  # Run mode for the workflow event. The run mode allows the user to optimize for
157
247
  # 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`.
248
+ # event. Available run modes (fastest to most thorough): `super_fast`, `fast`,
249
+ # `precision`, `precision_codex`, `precision_max`, and `precision_max_codex`.
250
+ # Defaults to `fast`. Note: `super_fast` does not support Web Search or File
251
+ # Search — if your workflow has these capabilities enabled, use a different run
252
+ # mode or edit the workflow to disable them.
160
253
  module RunMode
161
254
  extend Deeprails::Internal::Type::Enum
162
255
 
@@ -166,9 +259,14 @@ module Deeprails
166
259
  end
167
260
  OrSymbol = T.type_alias { T.any(Symbol, String) }
168
261
 
169
- PRECISION_PLUS =
262
+ SUPER_FAST =
170
263
  T.let(
171
- :precision_plus,
264
+ :super_fast,
265
+ Deeprails::DefendSubmitEventParams::RunMode::TaggedSymbol
266
+ )
267
+ FAST =
268
+ T.let(
269
+ :fast,
172
270
  Deeprails::DefendSubmitEventParams::RunMode::TaggedSymbol
173
271
  )
174
272
  PRECISION =
@@ -176,14 +274,19 @@ module Deeprails
176
274
  :precision,
177
275
  Deeprails::DefendSubmitEventParams::RunMode::TaggedSymbol
178
276
  )
179
- SMART =
277
+ PRECISION_CODEX =
278
+ T.let(
279
+ :precision_codex,
280
+ Deeprails::DefendSubmitEventParams::RunMode::TaggedSymbol
281
+ )
282
+ PRECISION_MAX =
180
283
  T.let(
181
- :smart,
284
+ :precision_max,
182
285
  Deeprails::DefendSubmitEventParams::RunMode::TaggedSymbol
183
286
  )
184
- ECONOMY =
287
+ PRECISION_MAX_CODEX =
185
288
  T.let(
186
- :economy,
289
+ :precision_max_codex,
187
290
  Deeprails::DefendSubmitEventParams::RunMode::TaggedSymbol
188
291
  )
189
292
 
@@ -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,198 @@ module Deeprails
14
14
  )
15
15
  end
16
16
 
17
- # Description for the workflow.
17
+ sig { returns(String) }
18
+ attr_accessor :workflow_id
19
+
20
+ # New mapping of guardrail metrics to hallucination tolerance levels (either
21
+ # `low`, `medium`, or `high`) to be used when `threshold_type` is set to
22
+ # `automatic`. Possible metrics are `completeness`, `instruction_adherence`,
23
+ # `context_adherence`, `ground_truth_adherence`, or `comprehensive_safety`.
24
+ sig do
25
+ returns(
26
+ T.nilable(
27
+ T::Hash[
28
+ Symbol,
29
+ Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::OrSymbol
30
+ ]
31
+ )
32
+ )
33
+ end
34
+ attr_reader :automatic_hallucination_tolerance_levels
35
+
36
+ sig do
37
+ params(
38
+ automatic_hallucination_tolerance_levels:
39
+ T::Hash[
40
+ Symbol,
41
+ Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::OrSymbol
42
+ ]
43
+ ).void
44
+ end
45
+ attr_writer :automatic_hallucination_tolerance_levels
46
+
47
+ # Whether to enable context awareness for this workflow's evaluations.
48
+ sig { returns(T.nilable(T::Boolean)) }
49
+ attr_reader :context_awareness
50
+
51
+ sig { params(context_awareness: T::Boolean).void }
52
+ attr_writer :context_awareness
53
+
54
+ # New mapping of guardrail metrics to floating point threshold values to be used
55
+ # when `threshold_type` is set to `custom`. Possible metrics are `correctness`,
56
+ # `completeness`, `instruction_adherence`, `context_adherence`,
57
+ # `ground_truth_adherence`, or `comprehensive_safety`.
58
+ sig { returns(T.nilable(T::Hash[Symbol, Float])) }
59
+ attr_reader :custom_hallucination_threshold_values
60
+
61
+ sig do
62
+ params(
63
+ custom_hallucination_threshold_values: T::Hash[Symbol, Float]
64
+ ).void
65
+ end
66
+ attr_writer :custom_hallucination_threshold_values
67
+
68
+ # New description for the workflow.
18
69
  sig { returns(T.nilable(String)) }
19
70
  attr_reader :description
20
71
 
21
72
  sig { params(description: String).void }
22
73
  attr_writer :description
23
74
 
24
- # Name of the workflow.
75
+ # An array of file IDs to search in the workflow's evaluations. Files must be
76
+ # uploaded via the DeepRails API first.
77
+ sig { returns(T.nilable(T::Array[String])) }
78
+ attr_reader :file_search
79
+
80
+ sig { params(file_search: T::Array[String]).void }
81
+ attr_writer :file_search
82
+
83
+ # The new action used to improve outputs that fail one or more guardrail metrics
84
+ # for the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs
85
+ # the user's input prompt with minor induced variance. FixIt attempts to directly
86
+ # address the shortcomings of the output using the guardrail failure rationale. Do
87
+ # Nothing does not attempt any improvement.
88
+ sig do
89
+ returns(
90
+ T.nilable(
91
+ Deeprails::DefendUpdateWorkflowParams::ImprovementAction::OrSymbol
92
+ )
93
+ )
94
+ end
95
+ attr_reader :improvement_action
96
+
97
+ sig do
98
+ params(
99
+ improvement_action:
100
+ Deeprails::DefendUpdateWorkflowParams::ImprovementAction::OrSymbol
101
+ ).void
102
+ end
103
+ attr_writer :improvement_action
104
+
105
+ # Max. number of improvement action attempts until a given event passes the
106
+ # guardrails. Defaults to 10.
107
+ sig { returns(T.nilable(Integer)) }
108
+ attr_reader :max_improvement_attempts
109
+
110
+ sig { params(max_improvement_attempts: Integer).void }
111
+ attr_writer :max_improvement_attempts
112
+
113
+ # New name for the workflow.
25
114
  sig { returns(T.nilable(String)) }
26
115
  attr_reader :name
27
116
 
28
117
  sig { params(name: String).void }
29
118
  attr_writer :name
30
119
 
120
+ # New type of thresholds to use for the workflow, either `automatic` or `custom`.
121
+ # Automatic thresholds are assigned internally after the user specifies a
122
+ # qualitative tolerance for the metrics, whereas custom metrics allow the user to
123
+ # set the threshold for each metric as a floating point number between 0.0 and
124
+ # 1.0.
125
+ sig do
126
+ returns(
127
+ T.nilable(
128
+ Deeprails::DefendUpdateWorkflowParams::ThresholdType::OrSymbol
129
+ )
130
+ )
131
+ end
132
+ attr_reader :threshold_type
133
+
31
134
  sig do
32
135
  params(
136
+ threshold_type:
137
+ Deeprails::DefendUpdateWorkflowParams::ThresholdType::OrSymbol
138
+ ).void
139
+ end
140
+ attr_writer :threshold_type
141
+
142
+ # Whether to enable web search for this workflow's evaluations.
143
+ sig { returns(T.nilable(T::Boolean)) }
144
+ attr_reader :web_search
145
+
146
+ sig { params(web_search: T::Boolean).void }
147
+ attr_writer :web_search
148
+
149
+ sig do
150
+ params(
151
+ workflow_id: String,
152
+ automatic_hallucination_tolerance_levels:
153
+ T::Hash[
154
+ Symbol,
155
+ Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::OrSymbol
156
+ ],
157
+ context_awareness: T::Boolean,
158
+ custom_hallucination_threshold_values: T::Hash[Symbol, Float],
33
159
  description: String,
160
+ file_search: T::Array[String],
161
+ improvement_action:
162
+ Deeprails::DefendUpdateWorkflowParams::ImprovementAction::OrSymbol,
163
+ max_improvement_attempts: Integer,
34
164
  name: String,
165
+ threshold_type:
166
+ Deeprails::DefendUpdateWorkflowParams::ThresholdType::OrSymbol,
167
+ web_search: T::Boolean,
35
168
  request_options: Deeprails::RequestOptions::OrHash
36
169
  ).returns(T.attached_class)
37
170
  end
38
171
  def self.new(
39
- # Description for the workflow.
172
+ workflow_id:,
173
+ # New mapping of guardrail metrics to hallucination tolerance levels (either
174
+ # `low`, `medium`, or `high`) to be used when `threshold_type` is set to
175
+ # `automatic`. Possible metrics are `completeness`, `instruction_adherence`,
176
+ # `context_adherence`, `ground_truth_adherence`, or `comprehensive_safety`.
177
+ automatic_hallucination_tolerance_levels: nil,
178
+ # Whether to enable context awareness for this workflow's evaluations.
179
+ context_awareness: nil,
180
+ # New mapping of guardrail metrics to floating point threshold values to be used
181
+ # when `threshold_type` is set to `custom`. Possible metrics are `correctness`,
182
+ # `completeness`, `instruction_adherence`, `context_adherence`,
183
+ # `ground_truth_adherence`, or `comprehensive_safety`.
184
+ custom_hallucination_threshold_values: nil,
185
+ # New description for the workflow.
40
186
  description: nil,
41
- # Name of the workflow.
187
+ # An array of file IDs to search in the workflow's evaluations. Files must be
188
+ # uploaded via the DeepRails API first.
189
+ file_search: nil,
190
+ # The new action used to improve outputs that fail one or more guardrail metrics
191
+ # for the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs
192
+ # the user's input prompt with minor induced variance. FixIt attempts to directly
193
+ # address the shortcomings of the output using the guardrail failure rationale. Do
194
+ # Nothing does not attempt any improvement.
195
+ improvement_action: nil,
196
+ # Max. number of improvement action attempts until a given event passes the
197
+ # guardrails. Defaults to 10.
198
+ max_improvement_attempts: nil,
199
+ # New name for the workflow.
42
200
  name: nil,
201
+ # New type of thresholds to use for the workflow, either `automatic` or `custom`.
202
+ # Automatic thresholds are assigned internally after the user specifies a
203
+ # qualitative tolerance for the metrics, whereas custom metrics allow the user to
204
+ # set the threshold for each metric as a floating point number between 0.0 and
205
+ # 1.0.
206
+ threshold_type: nil,
207
+ # Whether to enable web search for this workflow's evaluations.
208
+ web_search: nil,
43
209
  request_options: {}
44
210
  )
45
211
  end
@@ -47,14 +213,148 @@ module Deeprails
47
213
  sig do
48
214
  override.returns(
49
215
  {
216
+ workflow_id: String,
217
+ automatic_hallucination_tolerance_levels:
218
+ T::Hash[
219
+ Symbol,
220
+ Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::OrSymbol
221
+ ],
222
+ context_awareness: T::Boolean,
223
+ custom_hallucination_threshold_values: T::Hash[Symbol, Float],
50
224
  description: String,
225
+ file_search: T::Array[String],
226
+ improvement_action:
227
+ Deeprails::DefendUpdateWorkflowParams::ImprovementAction::OrSymbol,
228
+ max_improvement_attempts: Integer,
51
229
  name: String,
230
+ threshold_type:
231
+ Deeprails::DefendUpdateWorkflowParams::ThresholdType::OrSymbol,
232
+ web_search: T::Boolean,
52
233
  request_options: Deeprails::RequestOptions
53
234
  }
54
235
  )
55
236
  end
56
237
  def to_hash
57
238
  end
239
+
240
+ module AutomaticHallucinationToleranceLevel
241
+ extend Deeprails::Internal::Type::Enum
242
+
243
+ TaggedSymbol =
244
+ T.type_alias do
245
+ T.all(
246
+ Symbol,
247
+ Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel
248
+ )
249
+ end
250
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
251
+
252
+ LOW =
253
+ T.let(
254
+ :low,
255
+ Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::TaggedSymbol
256
+ )
257
+ MEDIUM =
258
+ T.let(
259
+ :medium,
260
+ Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::TaggedSymbol
261
+ )
262
+ HIGH =
263
+ T.let(
264
+ :high,
265
+ Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::TaggedSymbol
266
+ )
267
+
268
+ sig do
269
+ override.returns(
270
+ T::Array[
271
+ Deeprails::DefendUpdateWorkflowParams::AutomaticHallucinationToleranceLevel::TaggedSymbol
272
+ ]
273
+ )
274
+ end
275
+ def self.values
276
+ end
277
+ end
278
+
279
+ # The new action used to improve outputs that fail one or more guardrail metrics
280
+ # for the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs
281
+ # the user's input prompt with minor induced variance. FixIt attempts to directly
282
+ # address the shortcomings of the output using the guardrail failure rationale. Do
283
+ # Nothing does not attempt any improvement.
284
+ module ImprovementAction
285
+ extend Deeprails::Internal::Type::Enum
286
+
287
+ TaggedSymbol =
288
+ T.type_alias do
289
+ T.all(
290
+ Symbol,
291
+ Deeprails::DefendUpdateWorkflowParams::ImprovementAction
292
+ )
293
+ end
294
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
295
+
296
+ REGEN =
297
+ T.let(
298
+ :regen,
299
+ Deeprails::DefendUpdateWorkflowParams::ImprovementAction::TaggedSymbol
300
+ )
301
+ FIXIT =
302
+ T.let(
303
+ :fixit,
304
+ Deeprails::DefendUpdateWorkflowParams::ImprovementAction::TaggedSymbol
305
+ )
306
+ DO_NOTHING =
307
+ T.let(
308
+ :do_nothing,
309
+ Deeprails::DefendUpdateWorkflowParams::ImprovementAction::TaggedSymbol
310
+ )
311
+
312
+ sig do
313
+ override.returns(
314
+ T::Array[
315
+ Deeprails::DefendUpdateWorkflowParams::ImprovementAction::TaggedSymbol
316
+ ]
317
+ )
318
+ end
319
+ def self.values
320
+ end
321
+ end
322
+
323
+ # New type of thresholds to use for the workflow, either `automatic` or `custom`.
324
+ # Automatic thresholds are assigned internally after the user specifies a
325
+ # qualitative tolerance for the metrics, whereas custom metrics allow the user to
326
+ # set the threshold for each metric as a floating point number between 0.0 and
327
+ # 1.0.
328
+ module ThresholdType
329
+ extend Deeprails::Internal::Type::Enum
330
+
331
+ TaggedSymbol =
332
+ T.type_alias do
333
+ T.all(Symbol, Deeprails::DefendUpdateWorkflowParams::ThresholdType)
334
+ end
335
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
336
+
337
+ AUTOMATIC =
338
+ T.let(
339
+ :automatic,
340
+ Deeprails::DefendUpdateWorkflowParams::ThresholdType::TaggedSymbol
341
+ )
342
+ CUSTOM =
343
+ T.let(
344
+ :custom,
345
+ Deeprails::DefendUpdateWorkflowParams::ThresholdType::TaggedSymbol
346
+ )
347
+
348
+ sig do
349
+ override.returns(
350
+ T::Array[
351
+ Deeprails::DefendUpdateWorkflowParams::ThresholdType::TaggedSymbol
352
+ ]
353
+ )
354
+ end
355
+ def self.values
356
+ end
357
+ end
58
358
  end
59
359
  end
60
360
  end