deeprails 0.1.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.
- checksums.yaml +7 -0
- data/.ignore +2 -0
- data/CHANGELOG.md +18 -0
- data/README.md +273 -0
- data/SECURITY.md +27 -0
- data/lib/deeprails/client.rb +82 -0
- data/lib/deeprails/errors.rb +228 -0
- data/lib/deeprails/file_part.rb +58 -0
- data/lib/deeprails/internal/transport/base_client.rb +567 -0
- data/lib/deeprails/internal/transport/pooled_net_requester.rb +198 -0
- data/lib/deeprails/internal/type/array_of.rb +168 -0
- data/lib/deeprails/internal/type/base_model.rb +531 -0
- data/lib/deeprails/internal/type/base_page.rb +55 -0
- data/lib/deeprails/internal/type/boolean.rb +77 -0
- data/lib/deeprails/internal/type/converter.rb +327 -0
- data/lib/deeprails/internal/type/enum.rb +131 -0
- data/lib/deeprails/internal/type/file_input.rb +111 -0
- data/lib/deeprails/internal/type/hash_of.rb +188 -0
- data/lib/deeprails/internal/type/request_parameters.rb +42 -0
- data/lib/deeprails/internal/type/union.rb +237 -0
- data/lib/deeprails/internal/type/unknown.rb +81 -0
- data/lib/deeprails/internal/util.rb +915 -0
- data/lib/deeprails/internal.rb +20 -0
- data/lib/deeprails/models/api_response.rb +119 -0
- data/lib/deeprails/models/defend_create_workflow_params.rb +132 -0
- data/lib/deeprails/models/defend_response.rb +123 -0
- data/lib/deeprails/models/defend_retrieve_event_params.rb +20 -0
- data/lib/deeprails/models/defend_retrieve_workflow_params.rb +14 -0
- data/lib/deeprails/models/defend_submit_event_params.rb +98 -0
- data/lib/deeprails/models/defend_update_workflow_params.rb +49 -0
- data/lib/deeprails/models/evaluate_create_params.rb +123 -0
- data/lib/deeprails/models/evaluate_retrieve_params.rb +14 -0
- data/lib/deeprails/models/evaluation.rb +225 -0
- data/lib/deeprails/models/monitor_create_params.rb +30 -0
- data/lib/deeprails/models/monitor_retrieve_params.rb +22 -0
- data/lib/deeprails/models/monitor_retrieve_response.rb +186 -0
- data/lib/deeprails/models/monitor_submit_event_params.rb +124 -0
- data/lib/deeprails/models/monitor_submit_event_response.rb +77 -0
- data/lib/deeprails/models/monitor_update_params.rb +54 -0
- data/lib/deeprails/models/workflow_event_response.rb +57 -0
- data/lib/deeprails/models.rb +71 -0
- data/lib/deeprails/request_options.rb +77 -0
- data/lib/deeprails/resources/defend.rb +162 -0
- data/lib/deeprails/resources/evaluate.rb +70 -0
- data/lib/deeprails/resources/monitor.rb +130 -0
- data/lib/deeprails/version.rb +5 -0
- data/lib/deeprails.rb +73 -0
- data/manifest.yaml +15 -0
- data/rbi/deeprails/client.rbi +55 -0
- data/rbi/deeprails/errors.rbi +205 -0
- data/rbi/deeprails/file_part.rbi +37 -0
- data/rbi/deeprails/internal/transport/base_client.rbi +293 -0
- data/rbi/deeprails/internal/transport/pooled_net_requester.rbi +79 -0
- data/rbi/deeprails/internal/type/array_of.rbi +104 -0
- data/rbi/deeprails/internal/type/base_model.rbi +304 -0
- data/rbi/deeprails/internal/type/base_page.rbi +42 -0
- data/rbi/deeprails/internal/type/boolean.rbi +58 -0
- data/rbi/deeprails/internal/type/converter.rbi +216 -0
- data/rbi/deeprails/internal/type/enum.rbi +82 -0
- data/rbi/deeprails/internal/type/file_input.rbi +59 -0
- data/rbi/deeprails/internal/type/hash_of.rbi +104 -0
- data/rbi/deeprails/internal/type/request_parameters.rbi +29 -0
- data/rbi/deeprails/internal/type/union.rbi +128 -0
- data/rbi/deeprails/internal/type/unknown.rbi +58 -0
- data/rbi/deeprails/internal/util.rbi +487 -0
- data/rbi/deeprails/internal.rbi +18 -0
- data/rbi/deeprails/models/api_response.rbi +204 -0
- data/rbi/deeprails/models/defend_create_workflow_params.rbi +270 -0
- data/rbi/deeprails/models/defend_response.rbi +198 -0
- data/rbi/deeprails/models/defend_retrieve_event_params.rbi +38 -0
- data/rbi/deeprails/models/defend_retrieve_workflow_params.rbi +30 -0
- data/rbi/deeprails/models/defend_submit_event_params.rbi +170 -0
- data/rbi/deeprails/models/defend_update_workflow_params.rbi +107 -0
- data/rbi/deeprails/models/evaluate_create_params.rbi +253 -0
- data/rbi/deeprails/models/evaluate_retrieve_params.rbi +27 -0
- data/rbi/deeprails/models/evaluation.rbi +382 -0
- data/rbi/deeprails/models/monitor_create_params.rbi +54 -0
- data/rbi/deeprails/models/monitor_retrieve_params.rbi +43 -0
- data/rbi/deeprails/models/monitor_retrieve_response.rbi +336 -0
- data/rbi/deeprails/models/monitor_submit_event_params.rbi +264 -0
- data/rbi/deeprails/models/monitor_submit_event_response.rbi +134 -0
- data/rbi/deeprails/models/monitor_update_params.rbi +114 -0
- data/rbi/deeprails/models/workflow_event_response.rbi +85 -0
- data/rbi/deeprails/models.rbi +33 -0
- data/rbi/deeprails/request_options.rbi +59 -0
- data/rbi/deeprails/resources/defend.rbi +151 -0
- data/rbi/deeprails/resources/evaluate.rbi +66 -0
- data/rbi/deeprails/resources/monitor.rbi +114 -0
- data/rbi/deeprails/version.rbi +5 -0
- data/sig/deeprails/client.rbs +30 -0
- data/sig/deeprails/errors.rbs +117 -0
- data/sig/deeprails/file_part.rbs +21 -0
- data/sig/deeprails/internal/transport/base_client.rbs +131 -0
- data/sig/deeprails/internal/transport/pooled_net_requester.rbs +45 -0
- data/sig/deeprails/internal/type/array_of.rbs +48 -0
- data/sig/deeprails/internal/type/base_model.rbs +102 -0
- data/sig/deeprails/internal/type/base_page.rbs +24 -0
- data/sig/deeprails/internal/type/boolean.rbs +26 -0
- data/sig/deeprails/internal/type/converter.rbs +79 -0
- data/sig/deeprails/internal/type/enum.rbs +32 -0
- data/sig/deeprails/internal/type/file_input.rbs +25 -0
- data/sig/deeprails/internal/type/hash_of.rbs +48 -0
- data/sig/deeprails/internal/type/request_parameters.rbs +19 -0
- data/sig/deeprails/internal/type/union.rbs +52 -0
- data/sig/deeprails/internal/type/unknown.rbs +26 -0
- data/sig/deeprails/internal/util.rbs +185 -0
- data/sig/deeprails/internal.rbs +9 -0
- data/sig/deeprails/models/api_response.rbs +100 -0
- data/sig/deeprails/models/defend_create_workflow_params.rbs +98 -0
- data/sig/deeprails/models/defend_response.rbs +96 -0
- data/sig/deeprails/models/defend_retrieve_event_params.rbs +23 -0
- data/sig/deeprails/models/defend_retrieve_workflow_params.rbs +15 -0
- data/sig/deeprails/models/defend_submit_event_params.rbs +73 -0
- data/sig/deeprails/models/defend_update_workflow_params.rbs +55 -0
- data/sig/deeprails/models/evaluate_create_params.rbs +107 -0
- data/sig/deeprails/models/evaluate_retrieve_params.rbs +15 -0
- data/sig/deeprails/models/evaluation.rbs +189 -0
- data/sig/deeprails/models/monitor_create_params.rbs +30 -0
- data/sig/deeprails/models/monitor_retrieve_params.rbs +25 -0
- data/sig/deeprails/models/monitor_retrieve_response.rbs +167 -0
- data/sig/deeprails/models/monitor_submit_event_params.rbs +107 -0
- data/sig/deeprails/models/monitor_submit_event_response.rbs +70 -0
- data/sig/deeprails/models/monitor_update_params.rbs +55 -0
- data/sig/deeprails/models/workflow_event_response.rbs +46 -0
- data/sig/deeprails/models.rbs +31 -0
- data/sig/deeprails/request_options.rbs +34 -0
- data/sig/deeprails/resources/defend.rbs +47 -0
- data/sig/deeprails/resources/evaluate.rbs +22 -0
- data/sig/deeprails/resources/monitor.rbs +38 -0
- data/sig/deeprails/version.rbs +3 -0
- metadata +188 -0
@@ -0,0 +1,270 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Deeprails
|
4
|
+
module Models
|
5
|
+
class DefendCreateWorkflowParams < Deeprails::Internal::Type::BaseModel
|
6
|
+
extend Deeprails::Internal::Type::RequestParameters::Converter
|
7
|
+
include Deeprails::Internal::Type::RequestParameters
|
8
|
+
|
9
|
+
OrHash =
|
10
|
+
T.type_alias do
|
11
|
+
T.any(
|
12
|
+
Deeprails::DefendCreateWorkflowParams,
|
13
|
+
Deeprails::Internal::AnyHash
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
# The action used to improve outputs that fail one or guardrail metrics for the
|
18
|
+
# workflow events. May be `regenerate`, `fixit`, or null which represents “do
|
19
|
+
# nothing”. ReGen runs the user's exact input prompt with minor induced variance.
|
20
|
+
# Fixit attempts to directly address the shortcomings of the output using the
|
21
|
+
# guardrail failure rationale. Do nothing does not attempt any improvement.
|
22
|
+
sig do
|
23
|
+
returns(
|
24
|
+
T.nilable(
|
25
|
+
Deeprails::DefendCreateWorkflowParams::ImprovementAction::OrSymbol
|
26
|
+
)
|
27
|
+
)
|
28
|
+
end
|
29
|
+
attr_accessor :improvement_action
|
30
|
+
|
31
|
+
# Mapping of guardrail metrics to floating point threshold values. If the workflow
|
32
|
+
# type is automatic, only the metric names are used (`automatic_tolerance`
|
33
|
+
# determines thresholds). Possible metrics are `correctness`, `completeness`,
|
34
|
+
# `instruction_adherence`, `context_adherence`, `ground_truth_adherence`, or
|
35
|
+
# `comprehensive_safety`.
|
36
|
+
sig { returns(T::Hash[Symbol, Float]) }
|
37
|
+
attr_accessor :metrics
|
38
|
+
|
39
|
+
# Name of the workflow.
|
40
|
+
sig { returns(String) }
|
41
|
+
attr_accessor :name
|
42
|
+
|
43
|
+
# Type of thresholds to use for the workflow, either `automatic` or `custom`.
|
44
|
+
# Automatic thresholds are assigned internally after the user specifies a
|
45
|
+
# qualitative tolerance for the metrics, whereas custom metrics allow the user to
|
46
|
+
# set the threshold for each metric as a floating point number between 0.0 and
|
47
|
+
# 1.0.
|
48
|
+
sig { returns(Deeprails::DefendCreateWorkflowParams::Type::OrSymbol) }
|
49
|
+
attr_accessor :type
|
50
|
+
|
51
|
+
# Hallucination tolerance for automatic workflows; may be `low`, `medium`, or
|
52
|
+
# `high`. Ignored if `type` is `custom`.
|
53
|
+
sig do
|
54
|
+
returns(
|
55
|
+
T.nilable(
|
56
|
+
Deeprails::DefendCreateWorkflowParams::AutomaticTolerance::OrSymbol
|
57
|
+
)
|
58
|
+
)
|
59
|
+
end
|
60
|
+
attr_reader :automatic_tolerance
|
61
|
+
|
62
|
+
sig do
|
63
|
+
params(
|
64
|
+
automatic_tolerance:
|
65
|
+
Deeprails::DefendCreateWorkflowParams::AutomaticTolerance::OrSymbol
|
66
|
+
).void
|
67
|
+
end
|
68
|
+
attr_writer :automatic_tolerance
|
69
|
+
|
70
|
+
# Description for the workflow.
|
71
|
+
sig { returns(T.nilable(String)) }
|
72
|
+
attr_reader :description
|
73
|
+
|
74
|
+
sig { params(description: String).void }
|
75
|
+
attr_writer :description
|
76
|
+
|
77
|
+
# Max. number of improvement action retries until a given event passes the
|
78
|
+
# guardrails. Defaults to 10.
|
79
|
+
sig { returns(T.nilable(Integer)) }
|
80
|
+
attr_reader :max_retries
|
81
|
+
|
82
|
+
sig { params(max_retries: Integer).void }
|
83
|
+
attr_writer :max_retries
|
84
|
+
|
85
|
+
sig do
|
86
|
+
params(
|
87
|
+
improvement_action:
|
88
|
+
T.nilable(
|
89
|
+
Deeprails::DefendCreateWorkflowParams::ImprovementAction::OrSymbol
|
90
|
+
),
|
91
|
+
metrics: T::Hash[Symbol, Float],
|
92
|
+
name: String,
|
93
|
+
type: Deeprails::DefendCreateWorkflowParams::Type::OrSymbol,
|
94
|
+
automatic_tolerance:
|
95
|
+
Deeprails::DefendCreateWorkflowParams::AutomaticTolerance::OrSymbol,
|
96
|
+
description: String,
|
97
|
+
max_retries: Integer,
|
98
|
+
request_options: Deeprails::RequestOptions::OrHash
|
99
|
+
).returns(T.attached_class)
|
100
|
+
end
|
101
|
+
def self.new(
|
102
|
+
# The action used to improve outputs that fail one or guardrail metrics for the
|
103
|
+
# workflow events. May be `regenerate`, `fixit`, or null which represents “do
|
104
|
+
# nothing”. ReGen runs the user's exact input prompt with minor induced variance.
|
105
|
+
# Fixit attempts to directly address the shortcomings of the output using the
|
106
|
+
# guardrail failure rationale. Do nothing does not attempt any improvement.
|
107
|
+
improvement_action:,
|
108
|
+
# Mapping of guardrail metrics to floating point threshold values. If the workflow
|
109
|
+
# type is automatic, only the metric names are used (`automatic_tolerance`
|
110
|
+
# determines thresholds). Possible metrics are `correctness`, `completeness`,
|
111
|
+
# `instruction_adherence`, `context_adherence`, `ground_truth_adherence`, or
|
112
|
+
# `comprehensive_safety`.
|
113
|
+
metrics:,
|
114
|
+
# Name of the workflow.
|
115
|
+
name:,
|
116
|
+
# Type of thresholds to use for the workflow, either `automatic` or `custom`.
|
117
|
+
# Automatic thresholds are assigned internally after the user specifies a
|
118
|
+
# qualitative tolerance for the metrics, whereas custom metrics allow the user to
|
119
|
+
# set the threshold for each metric as a floating point number between 0.0 and
|
120
|
+
# 1.0.
|
121
|
+
type:,
|
122
|
+
# Hallucination tolerance for automatic workflows; may be `low`, `medium`, or
|
123
|
+
# `high`. Ignored if `type` is `custom`.
|
124
|
+
automatic_tolerance: nil,
|
125
|
+
# Description for the workflow.
|
126
|
+
description: nil,
|
127
|
+
# Max. number of improvement action retries until a given event passes the
|
128
|
+
# guardrails. Defaults to 10.
|
129
|
+
max_retries: nil,
|
130
|
+
request_options: {}
|
131
|
+
)
|
132
|
+
end
|
133
|
+
|
134
|
+
sig do
|
135
|
+
override.returns(
|
136
|
+
{
|
137
|
+
improvement_action:
|
138
|
+
T.nilable(
|
139
|
+
Deeprails::DefendCreateWorkflowParams::ImprovementAction::OrSymbol
|
140
|
+
),
|
141
|
+
metrics: T::Hash[Symbol, Float],
|
142
|
+
name: String,
|
143
|
+
type: Deeprails::DefendCreateWorkflowParams::Type::OrSymbol,
|
144
|
+
automatic_tolerance:
|
145
|
+
Deeprails::DefendCreateWorkflowParams::AutomaticTolerance::OrSymbol,
|
146
|
+
description: String,
|
147
|
+
max_retries: Integer,
|
148
|
+
request_options: Deeprails::RequestOptions
|
149
|
+
}
|
150
|
+
)
|
151
|
+
end
|
152
|
+
def to_hash
|
153
|
+
end
|
154
|
+
|
155
|
+
# The action used to improve outputs that fail one or guardrail metrics for the
|
156
|
+
# workflow events. May be `regenerate`, `fixit`, or null which represents “do
|
157
|
+
# nothing”. ReGen runs the user's exact input prompt with minor induced variance.
|
158
|
+
# Fixit attempts to directly address the shortcomings of the output using the
|
159
|
+
# guardrail failure rationale. Do nothing does not attempt any improvement.
|
160
|
+
module ImprovementAction
|
161
|
+
extend Deeprails::Internal::Type::Enum
|
162
|
+
|
163
|
+
TaggedSymbol =
|
164
|
+
T.type_alias do
|
165
|
+
T.all(
|
166
|
+
Symbol,
|
167
|
+
Deeprails::DefendCreateWorkflowParams::ImprovementAction
|
168
|
+
)
|
169
|
+
end
|
170
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
171
|
+
|
172
|
+
REGENERATE =
|
173
|
+
T.let(
|
174
|
+
:regenerate,
|
175
|
+
Deeprails::DefendCreateWorkflowParams::ImprovementAction::TaggedSymbol
|
176
|
+
)
|
177
|
+
FIXIT =
|
178
|
+
T.let(
|
179
|
+
:fixit,
|
180
|
+
Deeprails::DefendCreateWorkflowParams::ImprovementAction::TaggedSymbol
|
181
|
+
)
|
182
|
+
|
183
|
+
sig do
|
184
|
+
override.returns(
|
185
|
+
T::Array[
|
186
|
+
Deeprails::DefendCreateWorkflowParams::ImprovementAction::TaggedSymbol
|
187
|
+
]
|
188
|
+
)
|
189
|
+
end
|
190
|
+
def self.values
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# Type of thresholds to use for the workflow, either `automatic` or `custom`.
|
195
|
+
# Automatic thresholds are assigned internally after the user specifies a
|
196
|
+
# qualitative tolerance for the metrics, whereas custom metrics allow the user to
|
197
|
+
# set the threshold for each metric as a floating point number between 0.0 and
|
198
|
+
# 1.0.
|
199
|
+
module Type
|
200
|
+
extend Deeprails::Internal::Type::Enum
|
201
|
+
|
202
|
+
TaggedSymbol =
|
203
|
+
T.type_alias do
|
204
|
+
T.all(Symbol, Deeprails::DefendCreateWorkflowParams::Type)
|
205
|
+
end
|
206
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
207
|
+
|
208
|
+
AUTOMATIC =
|
209
|
+
T.let(
|
210
|
+
:automatic,
|
211
|
+
Deeprails::DefendCreateWorkflowParams::Type::TaggedSymbol
|
212
|
+
)
|
213
|
+
CUSTOM =
|
214
|
+
T.let(
|
215
|
+
:custom,
|
216
|
+
Deeprails::DefendCreateWorkflowParams::Type::TaggedSymbol
|
217
|
+
)
|
218
|
+
|
219
|
+
sig do
|
220
|
+
override.returns(
|
221
|
+
T::Array[Deeprails::DefendCreateWorkflowParams::Type::TaggedSymbol]
|
222
|
+
)
|
223
|
+
end
|
224
|
+
def self.values
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
# Hallucination tolerance for automatic workflows; may be `low`, `medium`, or
|
229
|
+
# `high`. Ignored if `type` is `custom`.
|
230
|
+
module AutomaticTolerance
|
231
|
+
extend Deeprails::Internal::Type::Enum
|
232
|
+
|
233
|
+
TaggedSymbol =
|
234
|
+
T.type_alias do
|
235
|
+
T.all(
|
236
|
+
Symbol,
|
237
|
+
Deeprails::DefendCreateWorkflowParams::AutomaticTolerance
|
238
|
+
)
|
239
|
+
end
|
240
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
241
|
+
|
242
|
+
LOW =
|
243
|
+
T.let(
|
244
|
+
:low,
|
245
|
+
Deeprails::DefendCreateWorkflowParams::AutomaticTolerance::TaggedSymbol
|
246
|
+
)
|
247
|
+
MEDIUM =
|
248
|
+
T.let(
|
249
|
+
:medium,
|
250
|
+
Deeprails::DefendCreateWorkflowParams::AutomaticTolerance::TaggedSymbol
|
251
|
+
)
|
252
|
+
HIGH =
|
253
|
+
T.let(
|
254
|
+
:high,
|
255
|
+
Deeprails::DefendCreateWorkflowParams::AutomaticTolerance::TaggedSymbol
|
256
|
+
)
|
257
|
+
|
258
|
+
sig do
|
259
|
+
override.returns(
|
260
|
+
T::Array[
|
261
|
+
Deeprails::DefendCreateWorkflowParams::AutomaticTolerance::TaggedSymbol
|
262
|
+
]
|
263
|
+
)
|
264
|
+
end
|
265
|
+
def self.values
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
@@ -0,0 +1,198 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Deeprails
|
4
|
+
module Models
|
5
|
+
class DefendResponse < Deeprails::Internal::Type::BaseModel
|
6
|
+
OrHash =
|
7
|
+
T.type_alias do
|
8
|
+
T.any(Deeprails::DefendResponse, Deeprails::Internal::AnyHash)
|
9
|
+
end
|
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 `regenerate`, `fixit`, or null which represents “do
|
35
|
+
# nothing”. ReGen runs the user's exact input prompt with minor induced variance.
|
36
|
+
# Fixit attempts to directly address the shortcomings of the output using the
|
37
|
+
# guardrail failure rationale. Do nothing does not attempt any improvement.
|
38
|
+
sig do
|
39
|
+
returns(
|
40
|
+
T.nilable(Deeprails::DefendResponse::ImprovementAction::TaggedSymbol)
|
41
|
+
)
|
42
|
+
end
|
43
|
+
attr_accessor :improvement_action
|
44
|
+
|
45
|
+
# Max. number of improvement action retries until a given event passes the
|
46
|
+
# guardrails.
|
47
|
+
sig { returns(T.nilable(Integer)) }
|
48
|
+
attr_reader :max_retries
|
49
|
+
|
50
|
+
sig { params(max_retries: Integer).void }
|
51
|
+
attr_writer :max_retries
|
52
|
+
|
53
|
+
# The most recent time the workflow was modified in UTC.
|
54
|
+
sig { returns(T.nilable(Time)) }
|
55
|
+
attr_reader :modified_at
|
56
|
+
|
57
|
+
sig { params(modified_at: Time).void }
|
58
|
+
attr_writer :modified_at
|
59
|
+
|
60
|
+
# Status of the selected workflow. May be `archived` or `active`. Archived
|
61
|
+
# workflows will not accept events.
|
62
|
+
sig do
|
63
|
+
returns(T.nilable(Deeprails::DefendResponse::Status::TaggedSymbol))
|
64
|
+
end
|
65
|
+
attr_reader :status
|
66
|
+
|
67
|
+
sig { params(status: Deeprails::DefendResponse::Status::OrSymbol).void }
|
68
|
+
attr_writer :status
|
69
|
+
|
70
|
+
# Rate of events associated with this workflow that passed evaluation.
|
71
|
+
sig { returns(T.nilable(Float)) }
|
72
|
+
attr_reader :success_rate
|
73
|
+
|
74
|
+
sig { params(success_rate: Float).void }
|
75
|
+
attr_writer :success_rate
|
76
|
+
|
77
|
+
# Response payload for guardrail workflow operations.
|
78
|
+
sig do
|
79
|
+
params(
|
80
|
+
name: String,
|
81
|
+
workflow_id: String,
|
82
|
+
created_at: Time,
|
83
|
+
description: String,
|
84
|
+
improvement_action:
|
85
|
+
T.nilable(Deeprails::DefendResponse::ImprovementAction::OrSymbol),
|
86
|
+
max_retries: Integer,
|
87
|
+
modified_at: Time,
|
88
|
+
status: Deeprails::DefendResponse::Status::OrSymbol,
|
89
|
+
success_rate: Float
|
90
|
+
).returns(T.attached_class)
|
91
|
+
end
|
92
|
+
def self.new(
|
93
|
+
# Name of the workflow.
|
94
|
+
name:,
|
95
|
+
# A unique workflow ID.
|
96
|
+
workflow_id:,
|
97
|
+
# The time the workflow was created in UTC.
|
98
|
+
created_at: nil,
|
99
|
+
# Description for the workflow.
|
100
|
+
description: nil,
|
101
|
+
# The action used to improve outputs that fail one or more guardrail metrics for
|
102
|
+
# the workflow events. May be `regenerate`, `fixit`, or null which represents “do
|
103
|
+
# nothing”. ReGen runs the user's exact input prompt with minor induced variance.
|
104
|
+
# Fixit attempts to directly address the shortcomings of the output using the
|
105
|
+
# guardrail failure rationale. Do nothing does not attempt any improvement.
|
106
|
+
improvement_action: nil,
|
107
|
+
# Max. number of improvement action retries until a given event passes the
|
108
|
+
# guardrails.
|
109
|
+
max_retries: nil,
|
110
|
+
# The most recent time the workflow was modified in UTC.
|
111
|
+
modified_at: nil,
|
112
|
+
# Status of the selected workflow. May be `archived` or `active`. Archived
|
113
|
+
# workflows will not accept events.
|
114
|
+
status: nil,
|
115
|
+
# Rate of events associated with this workflow that passed evaluation.
|
116
|
+
success_rate: nil
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
sig do
|
121
|
+
override.returns(
|
122
|
+
{
|
123
|
+
name: String,
|
124
|
+
workflow_id: String,
|
125
|
+
created_at: Time,
|
126
|
+
description: String,
|
127
|
+
improvement_action:
|
128
|
+
T.nilable(
|
129
|
+
Deeprails::DefendResponse::ImprovementAction::TaggedSymbol
|
130
|
+
),
|
131
|
+
max_retries: Integer,
|
132
|
+
modified_at: Time,
|
133
|
+
status: Deeprails::DefendResponse::Status::TaggedSymbol,
|
134
|
+
success_rate: Float
|
135
|
+
}
|
136
|
+
)
|
137
|
+
end
|
138
|
+
def to_hash
|
139
|
+
end
|
140
|
+
|
141
|
+
# The action used to improve outputs that fail one or more guardrail metrics for
|
142
|
+
# the workflow events. May be `regenerate`, `fixit`, or null which represents “do
|
143
|
+
# nothing”. ReGen runs the user's exact input prompt with minor induced variance.
|
144
|
+
# Fixit attempts to directly address the shortcomings of the output using the
|
145
|
+
# guardrail failure rationale. Do nothing does not attempt any improvement.
|
146
|
+
module ImprovementAction
|
147
|
+
extend Deeprails::Internal::Type::Enum
|
148
|
+
|
149
|
+
TaggedSymbol =
|
150
|
+
T.type_alias do
|
151
|
+
T.all(Symbol, Deeprails::DefendResponse::ImprovementAction)
|
152
|
+
end
|
153
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
154
|
+
|
155
|
+
REGENERATE =
|
156
|
+
T.let(
|
157
|
+
:regenerate,
|
158
|
+
Deeprails::DefendResponse::ImprovementAction::TaggedSymbol
|
159
|
+
)
|
160
|
+
FIXIT =
|
161
|
+
T.let(
|
162
|
+
:fixit,
|
163
|
+
Deeprails::DefendResponse::ImprovementAction::TaggedSymbol
|
164
|
+
)
|
165
|
+
|
166
|
+
sig do
|
167
|
+
override.returns(
|
168
|
+
T::Array[Deeprails::DefendResponse::ImprovementAction::TaggedSymbol]
|
169
|
+
)
|
170
|
+
end
|
171
|
+
def self.values
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# Status of the selected workflow. May be `archived` or `active`. Archived
|
176
|
+
# workflows will not accept events.
|
177
|
+
module Status
|
178
|
+
extend Deeprails::Internal::Type::Enum
|
179
|
+
|
180
|
+
TaggedSymbol =
|
181
|
+
T.type_alias { T.all(Symbol, Deeprails::DefendResponse::Status) }
|
182
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
183
|
+
|
184
|
+
ARCHIVED =
|
185
|
+
T.let(:archived, Deeprails::DefendResponse::Status::TaggedSymbol)
|
186
|
+
ACTIVE = T.let(:active, Deeprails::DefendResponse::Status::TaggedSymbol)
|
187
|
+
|
188
|
+
sig do
|
189
|
+
override.returns(
|
190
|
+
T::Array[Deeprails::DefendResponse::Status::TaggedSymbol]
|
191
|
+
)
|
192
|
+
end
|
193
|
+
def self.values
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Deeprails
|
4
|
+
module Models
|
5
|
+
class DefendRetrieveEventParams < Deeprails::Internal::Type::BaseModel
|
6
|
+
extend Deeprails::Internal::Type::RequestParameters::Converter
|
7
|
+
include Deeprails::Internal::Type::RequestParameters
|
8
|
+
|
9
|
+
OrHash =
|
10
|
+
T.type_alias do
|
11
|
+
T.any(
|
12
|
+
Deeprails::DefendRetrieveEventParams,
|
13
|
+
Deeprails::Internal::AnyHash
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
sig { returns(String) }
|
18
|
+
attr_accessor :workflow_id
|
19
|
+
|
20
|
+
sig do
|
21
|
+
params(
|
22
|
+
workflow_id: String,
|
23
|
+
request_options: Deeprails::RequestOptions::OrHash
|
24
|
+
).returns(T.attached_class)
|
25
|
+
end
|
26
|
+
def self.new(workflow_id:, request_options: {})
|
27
|
+
end
|
28
|
+
|
29
|
+
sig do
|
30
|
+
override.returns(
|
31
|
+
{ workflow_id: String, request_options: Deeprails::RequestOptions }
|
32
|
+
)
|
33
|
+
end
|
34
|
+
def to_hash
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Deeprails
|
4
|
+
module Models
|
5
|
+
class DefendRetrieveWorkflowParams < Deeprails::Internal::Type::BaseModel
|
6
|
+
extend Deeprails::Internal::Type::RequestParameters::Converter
|
7
|
+
include Deeprails::Internal::Type::RequestParameters
|
8
|
+
|
9
|
+
OrHash =
|
10
|
+
T.type_alias do
|
11
|
+
T.any(
|
12
|
+
Deeprails::DefendRetrieveWorkflowParams,
|
13
|
+
Deeprails::Internal::AnyHash
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
sig do
|
18
|
+
params(request_options: Deeprails::RequestOptions::OrHash).returns(
|
19
|
+
T.attached_class
|
20
|
+
)
|
21
|
+
end
|
22
|
+
def self.new(request_options: {})
|
23
|
+
end
|
24
|
+
|
25
|
+
sig { override.returns({ request_options: Deeprails::RequestOptions }) }
|
26
|
+
def to_hash
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Deeprails
|
4
|
+
module Models
|
5
|
+
class DefendSubmitEventParams < Deeprails::Internal::Type::BaseModel
|
6
|
+
extend Deeprails::Internal::Type::RequestParameters::Converter
|
7
|
+
include Deeprails::Internal::Type::RequestParameters
|
8
|
+
|
9
|
+
OrHash =
|
10
|
+
T.type_alias do
|
11
|
+
T.any(
|
12
|
+
Deeprails::DefendSubmitEventParams,
|
13
|
+
Deeprails::Internal::AnyHash
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
# A dictionary of inputs sent to the LLM to generate output. This must contain a
|
18
|
+
# `user_prompt` field and an optional `context` field. Additional properties are
|
19
|
+
# allowed.
|
20
|
+
sig { returns(Deeprails::DefendSubmitEventParams::ModelInput) }
|
21
|
+
attr_reader :model_input
|
22
|
+
|
23
|
+
sig do
|
24
|
+
params(
|
25
|
+
model_input: Deeprails::DefendSubmitEventParams::ModelInput::OrHash
|
26
|
+
).void
|
27
|
+
end
|
28
|
+
attr_writer :model_input
|
29
|
+
|
30
|
+
# Output generated by the LLM to be evaluated.
|
31
|
+
sig { returns(String) }
|
32
|
+
attr_accessor :model_output
|
33
|
+
|
34
|
+
# Model ID used to generate the output, like `gpt-4o` or `o3`.
|
35
|
+
sig { returns(String) }
|
36
|
+
attr_accessor :model_used
|
37
|
+
|
38
|
+
# An optional, user-defined tag for the event.
|
39
|
+
sig { returns(String) }
|
40
|
+
attr_accessor :nametag
|
41
|
+
|
42
|
+
# Run mode for the workflow event. The run mode allows the user to optimize for
|
43
|
+
# speed, accuracy, and cost by determining which models are used to evaluate the
|
44
|
+
# event. Available run modes include `precision_plus`, `precision`, `smart`, and
|
45
|
+
# `economy`. Defaults to `smart`.
|
46
|
+
sig { returns(Deeprails::DefendSubmitEventParams::RunMode::OrSymbol) }
|
47
|
+
attr_accessor :run_mode
|
48
|
+
|
49
|
+
sig do
|
50
|
+
params(
|
51
|
+
model_input: Deeprails::DefendSubmitEventParams::ModelInput::OrHash,
|
52
|
+
model_output: String,
|
53
|
+
model_used: String,
|
54
|
+
nametag: String,
|
55
|
+
run_mode: Deeprails::DefendSubmitEventParams::RunMode::OrSymbol,
|
56
|
+
request_options: Deeprails::RequestOptions::OrHash
|
57
|
+
).returns(T.attached_class)
|
58
|
+
end
|
59
|
+
def self.new(
|
60
|
+
# A dictionary of inputs sent to the LLM to generate output. This must contain a
|
61
|
+
# `user_prompt` field and an optional `context` field. Additional properties are
|
62
|
+
# allowed.
|
63
|
+
model_input:,
|
64
|
+
# Output generated by the LLM to be evaluated.
|
65
|
+
model_output:,
|
66
|
+
# Model ID used to generate the output, like `gpt-4o` or `o3`.
|
67
|
+
model_used:,
|
68
|
+
# An optional, user-defined tag for the event.
|
69
|
+
nametag:,
|
70
|
+
# Run mode for the workflow event. The run mode allows the user to optimize for
|
71
|
+
# speed, accuracy, and cost by determining which models are used to evaluate the
|
72
|
+
# event. Available run modes include `precision_plus`, `precision`, `smart`, and
|
73
|
+
# `economy`. Defaults to `smart`.
|
74
|
+
run_mode:,
|
75
|
+
request_options: {}
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
sig do
|
80
|
+
override.returns(
|
81
|
+
{
|
82
|
+
model_input: Deeprails::DefendSubmitEventParams::ModelInput,
|
83
|
+
model_output: String,
|
84
|
+
model_used: String,
|
85
|
+
nametag: String,
|
86
|
+
run_mode: Deeprails::DefendSubmitEventParams::RunMode::OrSymbol,
|
87
|
+
request_options: Deeprails::RequestOptions
|
88
|
+
}
|
89
|
+
)
|
90
|
+
end
|
91
|
+
def to_hash
|
92
|
+
end
|
93
|
+
|
94
|
+
class ModelInput < Deeprails::Internal::Type::BaseModel
|
95
|
+
OrHash =
|
96
|
+
T.type_alias do
|
97
|
+
T.any(
|
98
|
+
Deeprails::DefendSubmitEventParams::ModelInput,
|
99
|
+
Deeprails::Internal::AnyHash
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
sig { returns(String) }
|
104
|
+
attr_accessor :user_prompt
|
105
|
+
|
106
|
+
sig { returns(T.nilable(String)) }
|
107
|
+
attr_reader :context
|
108
|
+
|
109
|
+
sig { params(context: String).void }
|
110
|
+
attr_writer :context
|
111
|
+
|
112
|
+
# A dictionary of inputs sent to the LLM to generate output. This must contain a
|
113
|
+
# `user_prompt` field and an optional `context` field. Additional properties are
|
114
|
+
# allowed.
|
115
|
+
sig do
|
116
|
+
params(user_prompt: String, context: String).returns(T.attached_class)
|
117
|
+
end
|
118
|
+
def self.new(user_prompt:, context: nil)
|
119
|
+
end
|
120
|
+
|
121
|
+
sig { override.returns({ user_prompt: String, context: String }) }
|
122
|
+
def to_hash
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# Run mode for the workflow event. The run mode allows the user to optimize for
|
127
|
+
# speed, accuracy, and cost by determining which models are used to evaluate the
|
128
|
+
# event. Available run modes include `precision_plus`, `precision`, `smart`, and
|
129
|
+
# `economy`. Defaults to `smart`.
|
130
|
+
module RunMode
|
131
|
+
extend Deeprails::Internal::Type::Enum
|
132
|
+
|
133
|
+
TaggedSymbol =
|
134
|
+
T.type_alias do
|
135
|
+
T.all(Symbol, Deeprails::DefendSubmitEventParams::RunMode)
|
136
|
+
end
|
137
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
138
|
+
|
139
|
+
PRECISION_PLUS =
|
140
|
+
T.let(
|
141
|
+
:precision_plus,
|
142
|
+
Deeprails::DefendSubmitEventParams::RunMode::TaggedSymbol
|
143
|
+
)
|
144
|
+
PRECISION =
|
145
|
+
T.let(
|
146
|
+
:precision,
|
147
|
+
Deeprails::DefendSubmitEventParams::RunMode::TaggedSymbol
|
148
|
+
)
|
149
|
+
SMART =
|
150
|
+
T.let(
|
151
|
+
:smart,
|
152
|
+
Deeprails::DefendSubmitEventParams::RunMode::TaggedSymbol
|
153
|
+
)
|
154
|
+
ECONOMY =
|
155
|
+
T.let(
|
156
|
+
:economy,
|
157
|
+
Deeprails::DefendSubmitEventParams::RunMode::TaggedSymbol
|
158
|
+
)
|
159
|
+
|
160
|
+
sig do
|
161
|
+
override.returns(
|
162
|
+
T::Array[Deeprails::DefendSubmitEventParams::RunMode::TaggedSymbol]
|
163
|
+
)
|
164
|
+
end
|
165
|
+
def self.values
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|