deeprails 0.8.0 → 0.10.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 +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +23 -1
- data/lib/deeprails/client.rb +3 -3
- data/lib/deeprails/models/defend_create_workflow_params.rb +18 -1
- data/lib/deeprails/models/file_response.rb +49 -0
- data/lib/deeprails/models/file_upload_params.rb +22 -0
- data/lib/deeprails/models/monitor_detail_response.rb +231 -3
- data/lib/deeprails/models.rb +2 -4
- data/lib/deeprails/resources/defend.rb +5 -1
- data/lib/deeprails/resources/files.rb +37 -0
- data/lib/deeprails/version.rb +1 -1
- data/lib/deeprails.rb +3 -4
- data/rbi/deeprails/client.rbi +2 -2
- data/rbi/deeprails/models/defend_create_workflow_params.rbi +24 -0
- data/rbi/deeprails/models/file_response.rbi +84 -0
- data/rbi/deeprails/models/file_upload_params.rbi +43 -0
- data/rbi/deeprails/models/monitor_detail_response.rbi +483 -4
- data/rbi/deeprails/models.rbi +2 -4
- data/rbi/deeprails/resources/defend.rbi +7 -0
- data/rbi/deeprails/resources/files.rbi +26 -0
- data/sig/deeprails/client.rbs +1 -1
- data/sig/deeprails/models/defend_create_workflow_params.rbs +15 -1
- data/sig/deeprails/models/file_response.rbs +50 -0
- data/sig/deeprails/models/file_upload_params.rbs +24 -0
- data/sig/deeprails/models/monitor_detail_response.rbs +207 -6
- data/sig/deeprails/models.rbs +2 -4
- data/sig/deeprails/resources/defend.rbs +2 -0
- data/sig/deeprails/resources/files.rbs +12 -0
- metadata +11 -14
- data/lib/deeprails/models/evaluate_create_params.rb +0 -134
- data/lib/deeprails/models/evaluate_retrieve_params.rb +0 -14
- data/lib/deeprails/models/evaluation.rb +0 -233
- data/lib/deeprails/resources/evaluate.rb +0 -70
- data/rbi/deeprails/models/evaluate_create_params.rbi +0 -280
- data/rbi/deeprails/models/evaluate_retrieve_params.rbi +0 -27
- data/rbi/deeprails/models/evaluation.rbi +0 -402
- data/rbi/deeprails/resources/evaluate.rbi +0 -66
- data/sig/deeprails/models/evaluate_create_params.rbs +0 -122
- data/sig/deeprails/models/evaluate_retrieve_params.rbs +0 -15
- data/sig/deeprails/models/evaluation.rbs +0 -204
- data/sig/deeprails/resources/evaluate.rbs +0 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e97d49d00ebc0ed03f3be4d2e391e5091fdaf9cbb1fcd743e5800844c8f233c3
|
|
4
|
+
data.tar.gz: 98898cc7823efe565ccd8f7519318d9af31fd9f3197c870e467c53cdc67ceaea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 13b913ddb0433f6de13a5ea8a990b1ef1de1e308012fed87ffde7f42a21596508a280f56401e159a9c8a1a86b9b31d9825a13d35cd4d08486666bb4c57f434a7
|
|
7
|
+
data.tar.gz: 1326ee104ab1202895c1d3eb667be76c933584fad15979b01505ad6bdf06c07a433762d986e5a9a51fc928070d59f196f3c9bb52d36ae34d27c231a20c0a055e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.0 (2025-10-30)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.9.0...v0.10.0](https://github.com/deeprails/deeprails-ruby-sdk/compare/v0.9.0...v0.10.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** Add file and web search as extended ai capabilities ([9c3e153](https://github.com/deeprails/deeprails-ruby-sdk/commit/9c3e153565a92a3e4228ffd1193cff119f7acbfe))
|
|
10
|
+
* **api:** manual updates ([7c6bd65](https://github.com/deeprails/deeprails-ruby-sdk/commit/7c6bd65a0fdafc880b467aa2ab5bc587d300bf76))
|
|
11
|
+
|
|
12
|
+
## 0.9.0 (2025-10-29)
|
|
13
|
+
|
|
14
|
+
Full Changelog: [v0.8.0...v0.9.0](https://github.com/deeprails/deeprails-ruby-sdk/compare/v0.8.0...v0.9.0)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **api:** remove evaluate api ([733236c](https://github.com/deeprails/deeprails-ruby-sdk/commit/733236c71a7bad030caea5ebe42a3c8061e05ec6))
|
|
19
|
+
* **api:** remove evaluate references ([de622dd](https://github.com/deeprails/deeprails-ruby-sdk/commit/de622dd89f3c14f5db366bd425c1e4c68bc59886))
|
|
20
|
+
|
|
3
21
|
## 0.8.0 (2025-10-24)
|
|
4
22
|
|
|
5
23
|
Full Changelog: [v0.7.0...v0.8.0](https://github.com/deeprails/deeprails-ruby-sdk/compare/v0.7.0...v0.8.0)
|
data/README.md
CHANGED
|
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
|
|
|
15
15
|
<!-- x-release-please-start-version -->
|
|
16
16
|
|
|
17
17
|
```ruby
|
|
18
|
-
gem "deeprails", "~> 0.
|
|
18
|
+
gem "deeprails", "~> 0.10.0"
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
<!-- x-release-please-end -->
|
|
@@ -40,6 +40,28 @@ defend_response = deeprails.defend.create_workflow(
|
|
|
40
40
|
puts(defend_response.workflow_id)
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
### File uploads
|
|
44
|
+
|
|
45
|
+
Request parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, [`StringIO`](https://rubyapi.org/3.2/o/stringio), or more.
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
require "pathname"
|
|
49
|
+
|
|
50
|
+
# Use `Pathname` to send the filename and/or avoid paging a large file into memory:
|
|
51
|
+
file_response = deeprails.files.upload(file: Pathname("/path/to/file"))
|
|
52
|
+
|
|
53
|
+
# Alternatively, pass file contents or a `StringIO` directly:
|
|
54
|
+
file_response = deeprails.files.upload(file: File.read("/path/to/file"))
|
|
55
|
+
|
|
56
|
+
# Or, to control the filename and/or content type:
|
|
57
|
+
file = Deeprails::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…")
|
|
58
|
+
file_response = deeprails.files.upload(file: file)
|
|
59
|
+
|
|
60
|
+
puts(file_response.file_id)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Note that you can also pass a raw `IO` descriptor, but this disables retries, as the library can't be sure if the descriptor is a file or pipe (which cannot be rewound).
|
|
64
|
+
|
|
43
65
|
### Handling errors
|
|
44
66
|
|
|
45
67
|
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Deeprails::Errors::APIError` will be thrown:
|
data/lib/deeprails/client.rb
CHANGED
|
@@ -24,8 +24,8 @@ module Deeprails
|
|
|
24
24
|
# @return [Deeprails::Resources::Monitor]
|
|
25
25
|
attr_reader :monitor
|
|
26
26
|
|
|
27
|
-
# @return [Deeprails::Resources::
|
|
28
|
-
attr_reader :
|
|
27
|
+
# @return [Deeprails::Resources::Files]
|
|
28
|
+
attr_reader :files
|
|
29
29
|
|
|
30
30
|
# @api private
|
|
31
31
|
#
|
|
@@ -76,7 +76,7 @@ module Deeprails
|
|
|
76
76
|
|
|
77
77
|
@defend = Deeprails::Resources::Defend.new(client: self)
|
|
78
78
|
@monitor = Deeprails::Resources::Monitor.new(client: self)
|
|
79
|
-
@
|
|
79
|
+
@files = Deeprails::Resources::Files.new(client: self)
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
end
|
|
@@ -57,6 +57,13 @@ module Deeprails
|
|
|
57
57
|
# @return [String, nil]
|
|
58
58
|
optional :description, String
|
|
59
59
|
|
|
60
|
+
# @!attribute file_search
|
|
61
|
+
# An array of file IDs to search in the workflow's evaluations. Files must be
|
|
62
|
+
# uploaded via the DeepRails API first.
|
|
63
|
+
#
|
|
64
|
+
# @return [Array<String>, nil]
|
|
65
|
+
optional :file_search, Deeprails::Internal::Type::ArrayOf[String]
|
|
66
|
+
|
|
60
67
|
# @!attribute max_improvement_attempts
|
|
61
68
|
# Max. number of improvement action retries until a given event passes the
|
|
62
69
|
# guardrails. Defaults to 10.
|
|
@@ -64,7 +71,13 @@ module Deeprails
|
|
|
64
71
|
# @return [Integer, nil]
|
|
65
72
|
optional :max_improvement_attempts, Integer
|
|
66
73
|
|
|
67
|
-
# @!
|
|
74
|
+
# @!attribute web_search
|
|
75
|
+
# Whether to enable web search for this workflow's evaluations. Defaults to false.
|
|
76
|
+
#
|
|
77
|
+
# @return [Boolean, nil]
|
|
78
|
+
optional :web_search, Deeprails::Internal::Type::Boolean
|
|
79
|
+
|
|
80
|
+
# @!method initialize(improvement_action:, name:, type:, automatic_hallucination_tolerance_levels: nil, custom_hallucination_threshold_values: nil, description: nil, file_search: nil, max_improvement_attempts: nil, web_search: nil, request_options: {})
|
|
68
81
|
# Some parameter documentations has been truncated, see
|
|
69
82
|
# {Deeprails::Models::DefendCreateWorkflowParams} for more details.
|
|
70
83
|
#
|
|
@@ -80,8 +93,12 @@ module Deeprails
|
|
|
80
93
|
#
|
|
81
94
|
# @param description [String] Description for the workflow.
|
|
82
95
|
#
|
|
96
|
+
# @param file_search [Array<String>] An array of file IDs to search in the workflow's evaluations. Files must be uplo
|
|
97
|
+
#
|
|
83
98
|
# @param max_improvement_attempts [Integer] Max. number of improvement action retries until a given event passes the guardra
|
|
84
99
|
#
|
|
100
|
+
# @param web_search [Boolean] Whether to enable web search for this workflow's evaluations. Defaults to false.
|
|
101
|
+
#
|
|
85
102
|
# @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}]
|
|
86
103
|
|
|
87
104
|
# The action used to improve outputs that fail one or guardrail metrics for the
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Deeprails
|
|
4
|
+
module Models
|
|
5
|
+
# @see Deeprails::Resources::Files#upload
|
|
6
|
+
class FileResponse < Deeprails::Internal::Type::BaseModel
|
|
7
|
+
# @!attribute created_at
|
|
8
|
+
# The time the file was created in UTC.
|
|
9
|
+
#
|
|
10
|
+
# @return [Time, nil]
|
|
11
|
+
optional :created_at, Time
|
|
12
|
+
|
|
13
|
+
# @!attribute file_id
|
|
14
|
+
# A unique file ID.
|
|
15
|
+
#
|
|
16
|
+
# @return [String, nil]
|
|
17
|
+
optional :file_id, String
|
|
18
|
+
|
|
19
|
+
# @!attribute file_name
|
|
20
|
+
# Name of the file.
|
|
21
|
+
#
|
|
22
|
+
# @return [String, nil]
|
|
23
|
+
optional :file_name, String
|
|
24
|
+
|
|
25
|
+
# @!attribute file_path
|
|
26
|
+
# Path to the s3 bucket where the file is stored.
|
|
27
|
+
#
|
|
28
|
+
# @return [String, nil]
|
|
29
|
+
optional :file_path, String
|
|
30
|
+
|
|
31
|
+
# @!attribute updated_at
|
|
32
|
+
# The most recent time the file was modified in UTC.
|
|
33
|
+
#
|
|
34
|
+
# @return [Time, nil]
|
|
35
|
+
optional :updated_at, Time
|
|
36
|
+
|
|
37
|
+
# @!method initialize(created_at: nil, file_id: nil, file_name: nil, file_path: nil, updated_at: nil)
|
|
38
|
+
# @param created_at [Time] The time the file was created in UTC.
|
|
39
|
+
#
|
|
40
|
+
# @param file_id [String] A unique file ID.
|
|
41
|
+
#
|
|
42
|
+
# @param file_name [String] Name of the file.
|
|
43
|
+
#
|
|
44
|
+
# @param file_path [String] Path to the s3 bucket where the file is stored.
|
|
45
|
+
#
|
|
46
|
+
# @param updated_at [Time] The most recent time the file was modified in UTC.
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Deeprails
|
|
4
|
+
module Models
|
|
5
|
+
# @see Deeprails::Resources::Files#upload
|
|
6
|
+
class FileUploadParams < Deeprails::Internal::Type::BaseModel
|
|
7
|
+
extend Deeprails::Internal::Type::RequestParameters::Converter
|
|
8
|
+
include Deeprails::Internal::Type::RequestParameters
|
|
9
|
+
|
|
10
|
+
# @!attribute file
|
|
11
|
+
# The contents of the file to upload.
|
|
12
|
+
#
|
|
13
|
+
# @return [Pathname, StringIO, IO, String, Deeprails::FilePart]
|
|
14
|
+
required :file, Deeprails::Internal::Type::FileInput
|
|
15
|
+
|
|
16
|
+
# @!method initialize(file:, request_options: {})
|
|
17
|
+
# @param file [Pathname, StringIO, IO, String, Deeprails::FilePart] The contents of the file to upload.
|
|
18
|
+
#
|
|
19
|
+
# @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}]
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -39,8 +39,9 @@ module Deeprails
|
|
|
39
39
|
# An array of all evaluations performed by this monitor. Each one corresponds to a
|
|
40
40
|
# separate monitor event.
|
|
41
41
|
#
|
|
42
|
-
# @return [Array<Deeprails::Models::Evaluation>, nil]
|
|
43
|
-
optional :evaluations,
|
|
42
|
+
# @return [Array<Deeprails::Models::MonitorDetailResponse::Evaluation>, nil]
|
|
43
|
+
optional :evaluations,
|
|
44
|
+
-> { Deeprails::Internal::Type::ArrayOf[Deeprails::MonitorDetailResponse::Evaluation] }
|
|
44
45
|
|
|
45
46
|
# @!attribute stats
|
|
46
47
|
# Contains five fields used for stats of this monitor: total evaluations,
|
|
@@ -76,7 +77,7 @@ module Deeprails
|
|
|
76
77
|
#
|
|
77
78
|
# @param description [String] Description of this monitor.
|
|
78
79
|
#
|
|
79
|
-
# @param evaluations [Array<Deeprails::Models::Evaluation>] An array of all evaluations performed by this monitor. Each one corresponds to
|
|
80
|
+
# @param evaluations [Array<Deeprails::Models::MonitorDetailResponse::Evaluation>] An array of all evaluations performed by this monitor. Each one corresponds to
|
|
80
81
|
#
|
|
81
82
|
# @param stats [Deeprails::Models::MonitorDetailResponse::Stats] Contains five fields used for stats of this monitor: total evaluations, complete
|
|
82
83
|
#
|
|
@@ -98,6 +99,233 @@ module Deeprails
|
|
|
98
99
|
# @return [Array<Symbol>]
|
|
99
100
|
end
|
|
100
101
|
|
|
102
|
+
class Evaluation < Deeprails::Internal::Type::BaseModel
|
|
103
|
+
# @!attribute eval_id
|
|
104
|
+
# A unique evaluation ID.
|
|
105
|
+
#
|
|
106
|
+
# @return [String]
|
|
107
|
+
required :eval_id, String
|
|
108
|
+
|
|
109
|
+
# @!attribute evaluation_status
|
|
110
|
+
# Status of the evaluation.
|
|
111
|
+
#
|
|
112
|
+
# @return [Symbol, Deeprails::Models::MonitorDetailResponse::Evaluation::EvaluationStatus]
|
|
113
|
+
required :evaluation_status, enum: -> { Deeprails::MonitorDetailResponse::Evaluation::EvaluationStatus }
|
|
114
|
+
|
|
115
|
+
# @!attribute model_input
|
|
116
|
+
# A dictionary of inputs sent to the LLM to generate output. The dictionary must
|
|
117
|
+
# contain at least a `user_prompt` field or a `system_prompt` field. For
|
|
118
|
+
# ground_truth_adherence guardrail metric, `ground_truth` should be provided.
|
|
119
|
+
#
|
|
120
|
+
# @return [Deeprails::Models::MonitorDetailResponse::Evaluation::ModelInput]
|
|
121
|
+
required :model_input, -> { Deeprails::MonitorDetailResponse::Evaluation::ModelInput }
|
|
122
|
+
|
|
123
|
+
# @!attribute model_output
|
|
124
|
+
# Output generated by the LLM to be evaluated.
|
|
125
|
+
#
|
|
126
|
+
# @return [String]
|
|
127
|
+
required :model_output, String
|
|
128
|
+
|
|
129
|
+
# @!attribute run_mode
|
|
130
|
+
# Run mode for the evaluation. The run mode allows the user to optimize for speed,
|
|
131
|
+
# accuracy, and cost by determining which models are used to evaluate the event.
|
|
132
|
+
#
|
|
133
|
+
# @return [Symbol, Deeprails::Models::MonitorDetailResponse::Evaluation::RunMode]
|
|
134
|
+
required :run_mode, enum: -> { Deeprails::MonitorDetailResponse::Evaluation::RunMode }
|
|
135
|
+
|
|
136
|
+
# @!attribute created_at
|
|
137
|
+
# The time the evaluation was created in UTC.
|
|
138
|
+
#
|
|
139
|
+
# @return [Time, nil]
|
|
140
|
+
optional :created_at, Time
|
|
141
|
+
|
|
142
|
+
# @!attribute end_timestamp
|
|
143
|
+
# The time the evaluation completed in UTC.
|
|
144
|
+
#
|
|
145
|
+
# @return [Time, nil]
|
|
146
|
+
optional :end_timestamp, Time
|
|
147
|
+
|
|
148
|
+
# @!attribute error_message
|
|
149
|
+
# Description of the error causing the evaluation to fail, if any.
|
|
150
|
+
#
|
|
151
|
+
# @return [String, nil]
|
|
152
|
+
optional :error_message, String
|
|
153
|
+
|
|
154
|
+
# @!attribute error_timestamp
|
|
155
|
+
# The time the error causing the evaluation to fail was recorded.
|
|
156
|
+
#
|
|
157
|
+
# @return [Time, nil]
|
|
158
|
+
optional :error_timestamp, Time
|
|
159
|
+
|
|
160
|
+
# @!attribute evaluation_result
|
|
161
|
+
# Evaluation result consisting of average scores and rationales for each of the
|
|
162
|
+
# evaluated guardrail metrics.
|
|
163
|
+
#
|
|
164
|
+
# @return [Hash{Symbol=>Object}, nil]
|
|
165
|
+
optional :evaluation_result, Deeprails::Internal::Type::HashOf[Deeprails::Internal::Type::Unknown]
|
|
166
|
+
|
|
167
|
+
# @!attribute evaluation_total_cost
|
|
168
|
+
# Total cost of the evaluation.
|
|
169
|
+
#
|
|
170
|
+
# @return [Float, nil]
|
|
171
|
+
optional :evaluation_total_cost, Float
|
|
172
|
+
|
|
173
|
+
# @!attribute guardrail_metrics
|
|
174
|
+
# An array of guardrail metrics that the model input and output pair will be
|
|
175
|
+
# evaluated on.
|
|
176
|
+
#
|
|
177
|
+
# @return [Array<Symbol, Deeprails::Models::MonitorDetailResponse::Evaluation::GuardrailMetric>, nil]
|
|
178
|
+
optional :guardrail_metrics,
|
|
179
|
+
-> { Deeprails::Internal::Type::ArrayOf[enum: Deeprails::MonitorDetailResponse::Evaluation::GuardrailMetric] }
|
|
180
|
+
|
|
181
|
+
# @!attribute model_used
|
|
182
|
+
# Model ID used to generate the output, like `gpt-4o` or `o3`.
|
|
183
|
+
#
|
|
184
|
+
# @return [String, nil]
|
|
185
|
+
optional :model_used, String
|
|
186
|
+
|
|
187
|
+
# @!attribute modified_at
|
|
188
|
+
# The most recent time the evaluation was modified in UTC.
|
|
189
|
+
#
|
|
190
|
+
# @return [Time, nil]
|
|
191
|
+
optional :modified_at, Time
|
|
192
|
+
|
|
193
|
+
# @!attribute nametag
|
|
194
|
+
# An optional, user-defined tag for the evaluation.
|
|
195
|
+
#
|
|
196
|
+
# @return [String, nil]
|
|
197
|
+
optional :nametag, String
|
|
198
|
+
|
|
199
|
+
# @!attribute progress
|
|
200
|
+
# Evaluation progress. Values range between 0 and 100; 100 corresponds to a
|
|
201
|
+
# completed `evaluation_status`.
|
|
202
|
+
#
|
|
203
|
+
# @return [Integer, nil]
|
|
204
|
+
optional :progress, Integer
|
|
205
|
+
|
|
206
|
+
# @!attribute start_timestamp
|
|
207
|
+
# The time the evaluation started in UTC.
|
|
208
|
+
#
|
|
209
|
+
# @return [Time, nil]
|
|
210
|
+
optional :start_timestamp, Time
|
|
211
|
+
|
|
212
|
+
# @!method initialize(eval_id:, evaluation_status:, model_input:, model_output:, run_mode:, created_at: nil, end_timestamp: nil, error_message: nil, error_timestamp: nil, evaluation_result: nil, evaluation_total_cost: nil, guardrail_metrics: nil, model_used: nil, modified_at: nil, nametag: nil, progress: nil, start_timestamp: nil)
|
|
213
|
+
# Some parameter documentations has been truncated, see
|
|
214
|
+
# {Deeprails::Models::MonitorDetailResponse::Evaluation} for more details.
|
|
215
|
+
#
|
|
216
|
+
# @param eval_id [String] A unique evaluation ID.
|
|
217
|
+
#
|
|
218
|
+
# @param evaluation_status [Symbol, Deeprails::Models::MonitorDetailResponse::Evaluation::EvaluationStatus] Status of the evaluation.
|
|
219
|
+
#
|
|
220
|
+
# @param model_input [Deeprails::Models::MonitorDetailResponse::Evaluation::ModelInput] A dictionary of inputs sent to the LLM to generate output. The dictionary must c
|
|
221
|
+
#
|
|
222
|
+
# @param model_output [String] Output generated by the LLM to be evaluated.
|
|
223
|
+
#
|
|
224
|
+
# @param run_mode [Symbol, Deeprails::Models::MonitorDetailResponse::Evaluation::RunMode] Run mode for the evaluation. The run mode allows the user to optimize for speed
|
|
225
|
+
#
|
|
226
|
+
# @param created_at [Time] The time the evaluation was created in UTC.
|
|
227
|
+
#
|
|
228
|
+
# @param end_timestamp [Time] The time the evaluation completed in UTC.
|
|
229
|
+
#
|
|
230
|
+
# @param error_message [String] Description of the error causing the evaluation to fail, if any.
|
|
231
|
+
#
|
|
232
|
+
# @param error_timestamp [Time] The time the error causing the evaluation to fail was recorded.
|
|
233
|
+
#
|
|
234
|
+
# @param evaluation_result [Hash{Symbol=>Object}] Evaluation result consisting of average scores and rationales for each of the ev
|
|
235
|
+
#
|
|
236
|
+
# @param evaluation_total_cost [Float] Total cost of the evaluation.
|
|
237
|
+
#
|
|
238
|
+
# @param guardrail_metrics [Array<Symbol, Deeprails::Models::MonitorDetailResponse::Evaluation::GuardrailMetric>] An array of guardrail metrics that the model input and output pair will be evalu
|
|
239
|
+
#
|
|
240
|
+
# @param model_used [String] Model ID used to generate the output, like `gpt-4o` or `o3`.
|
|
241
|
+
#
|
|
242
|
+
# @param modified_at [Time] The most recent time the evaluation was modified in UTC.
|
|
243
|
+
#
|
|
244
|
+
# @param nametag [String] An optional, user-defined tag for the evaluation.
|
|
245
|
+
#
|
|
246
|
+
# @param progress [Integer] Evaluation progress. Values range between 0 and 100; 100 corresponds to a compl
|
|
247
|
+
#
|
|
248
|
+
# @param start_timestamp [Time] The time the evaluation started in UTC.
|
|
249
|
+
|
|
250
|
+
# Status of the evaluation.
|
|
251
|
+
#
|
|
252
|
+
# @see Deeprails::Models::MonitorDetailResponse::Evaluation#evaluation_status
|
|
253
|
+
module EvaluationStatus
|
|
254
|
+
extend Deeprails::Internal::Type::Enum
|
|
255
|
+
|
|
256
|
+
IN_PROGRESS = :in_progress
|
|
257
|
+
COMPLETED = :completed
|
|
258
|
+
CANCELED = :canceled
|
|
259
|
+
QUEUED = :queued
|
|
260
|
+
FAILED = :failed
|
|
261
|
+
|
|
262
|
+
# @!method self.values
|
|
263
|
+
# @return [Array<Symbol>]
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
# @see Deeprails::Models::MonitorDetailResponse::Evaluation#model_input
|
|
267
|
+
class ModelInput < Deeprails::Internal::Type::BaseModel
|
|
268
|
+
# @!attribute ground_truth
|
|
269
|
+
# The ground truth for evaluating Ground Truth Adherence guardrail.
|
|
270
|
+
#
|
|
271
|
+
# @return [String, nil]
|
|
272
|
+
optional :ground_truth, String
|
|
273
|
+
|
|
274
|
+
# @!attribute system_prompt
|
|
275
|
+
# The system prompt used to generate the output.
|
|
276
|
+
#
|
|
277
|
+
# @return [String, nil]
|
|
278
|
+
optional :system_prompt, String
|
|
279
|
+
|
|
280
|
+
# @!attribute user_prompt
|
|
281
|
+
# The user prompt used to generate the output.
|
|
282
|
+
#
|
|
283
|
+
# @return [String, nil]
|
|
284
|
+
optional :user_prompt, String
|
|
285
|
+
|
|
286
|
+
# @!method initialize(ground_truth: nil, system_prompt: nil, user_prompt: nil)
|
|
287
|
+
# A dictionary of inputs sent to the LLM to generate output. The dictionary must
|
|
288
|
+
# contain at least a `user_prompt` field or a `system_prompt` field. For
|
|
289
|
+
# ground_truth_adherence guardrail metric, `ground_truth` should be provided.
|
|
290
|
+
#
|
|
291
|
+
# @param ground_truth [String] The ground truth for evaluating Ground Truth Adherence guardrail.
|
|
292
|
+
#
|
|
293
|
+
# @param system_prompt [String] The system prompt used to generate the output.
|
|
294
|
+
#
|
|
295
|
+
# @param user_prompt [String] The user prompt used to generate the output.
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
# Run mode for the evaluation. The run mode allows the user to optimize for speed,
|
|
299
|
+
# accuracy, and cost by determining which models are used to evaluate the event.
|
|
300
|
+
#
|
|
301
|
+
# @see Deeprails::Models::MonitorDetailResponse::Evaluation#run_mode
|
|
302
|
+
module RunMode
|
|
303
|
+
extend Deeprails::Internal::Type::Enum
|
|
304
|
+
|
|
305
|
+
PRECISION_PLUS = :precision_plus
|
|
306
|
+
PRECISION = :precision
|
|
307
|
+
SMART = :smart
|
|
308
|
+
ECONOMY = :economy
|
|
309
|
+
|
|
310
|
+
# @!method self.values
|
|
311
|
+
# @return [Array<Symbol>]
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
module GuardrailMetric
|
|
315
|
+
extend Deeprails::Internal::Type::Enum
|
|
316
|
+
|
|
317
|
+
CORRECTNESS = :correctness
|
|
318
|
+
COMPLETENESS = :completeness
|
|
319
|
+
INSTRUCTION_ADHERENCE = :instruction_adherence
|
|
320
|
+
CONTEXT_ADHERENCE = :context_adherence
|
|
321
|
+
GROUND_TRUTH_ADHERENCE = :ground_truth_adherence
|
|
322
|
+
COMPREHENSIVE_SAFETY = :comprehensive_safety
|
|
323
|
+
|
|
324
|
+
# @!method self.values
|
|
325
|
+
# @return [Array<Symbol>]
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
|
|
101
329
|
# @see Deeprails::Models::MonitorDetailResponse#stats
|
|
102
330
|
class Stats < Deeprails::Internal::Type::BaseModel
|
|
103
331
|
# @!attribute completed_evaluations
|
data/lib/deeprails/models.rb
CHANGED
|
@@ -51,11 +51,9 @@ module Deeprails
|
|
|
51
51
|
|
|
52
52
|
DefendUpdateWorkflowParams = Deeprails::Models::DefendUpdateWorkflowParams
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
FileResponse = Deeprails::Models::FileResponse
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
Evaluation = Deeprails::Models::Evaluation
|
|
56
|
+
FileUploadParams = Deeprails::Models::FileUploadParams
|
|
59
57
|
|
|
60
58
|
MonitorCreateParams = Deeprails::Models::MonitorCreateParams
|
|
61
59
|
|
|
@@ -9,7 +9,7 @@ module Deeprails
|
|
|
9
9
|
# Use this endpoint to create a new guardrail workflow with optional guardrail
|
|
10
10
|
# thresholds and improvement actions
|
|
11
11
|
#
|
|
12
|
-
# @overload create_workflow(improvement_action:, name:, type:, automatic_hallucination_tolerance_levels: nil, custom_hallucination_threshold_values: nil, description: nil, max_improvement_attempts: nil, request_options: {})
|
|
12
|
+
# @overload create_workflow(improvement_action:, name:, type:, automatic_hallucination_tolerance_levels: nil, custom_hallucination_threshold_values: nil, description: nil, file_search: nil, max_improvement_attempts: nil, web_search: nil, request_options: {})
|
|
13
13
|
#
|
|
14
14
|
# @param improvement_action [Symbol, Deeprails::Models::DefendCreateWorkflowParams::ImprovementAction] The action used to improve outputs that fail one or guardrail metrics for the wo
|
|
15
15
|
#
|
|
@@ -23,8 +23,12 @@ module Deeprails
|
|
|
23
23
|
#
|
|
24
24
|
# @param description [String] Description for the workflow.
|
|
25
25
|
#
|
|
26
|
+
# @param file_search [Array<String>] An array of file IDs to search in the workflow's evaluations. Files must be uplo
|
|
27
|
+
#
|
|
26
28
|
# @param max_improvement_attempts [Integer] Max. number of improvement action retries until a given event passes the guardra
|
|
27
29
|
#
|
|
30
|
+
# @param web_search [Boolean] Whether to enable web search for this workflow's evaluations. Defaults to false.
|
|
31
|
+
#
|
|
28
32
|
# @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
29
33
|
#
|
|
30
34
|
# @return [Deeprails::Models::DefendResponse]
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Deeprails
|
|
4
|
+
module Resources
|
|
5
|
+
class Files
|
|
6
|
+
# Use this endpoint to upload a file to the DeepRails API
|
|
7
|
+
#
|
|
8
|
+
# @overload upload(file:, request_options: {})
|
|
9
|
+
#
|
|
10
|
+
# @param file [Pathname, StringIO, IO, String, Deeprails::FilePart] The contents of the file to upload.
|
|
11
|
+
#
|
|
12
|
+
# @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
13
|
+
#
|
|
14
|
+
# @return [Deeprails::Models::FileResponse]
|
|
15
|
+
#
|
|
16
|
+
# @see Deeprails::Models::FileUploadParams
|
|
17
|
+
def upload(params)
|
|
18
|
+
parsed, options = Deeprails::FileUploadParams.dump_request(params)
|
|
19
|
+
@client.request(
|
|
20
|
+
method: :post,
|
|
21
|
+
path: "files/upload",
|
|
22
|
+
headers: {"content-type" => "multipart/form-data"},
|
|
23
|
+
body: parsed,
|
|
24
|
+
model: Deeprails::FileResponse,
|
|
25
|
+
options: options
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @api private
|
|
30
|
+
#
|
|
31
|
+
# @param client [Deeprails::Client]
|
|
32
|
+
def initialize(client:)
|
|
33
|
+
@client = client
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/deeprails/version.rb
CHANGED
data/lib/deeprails.rb
CHANGED
|
@@ -56,9 +56,8 @@ require_relative "deeprails/models/defend_retrieve_event_params"
|
|
|
56
56
|
require_relative "deeprails/models/defend_retrieve_workflow_params"
|
|
57
57
|
require_relative "deeprails/models/defend_submit_event_params"
|
|
58
58
|
require_relative "deeprails/models/defend_update_workflow_params"
|
|
59
|
-
require_relative "deeprails/models/
|
|
60
|
-
require_relative "deeprails/models/
|
|
61
|
-
require_relative "deeprails/models/evaluation"
|
|
59
|
+
require_relative "deeprails/models/file_response"
|
|
60
|
+
require_relative "deeprails/models/file_upload_params"
|
|
62
61
|
require_relative "deeprails/models/monitor_create_params"
|
|
63
62
|
require_relative "deeprails/models/monitor_detail_response"
|
|
64
63
|
require_relative "deeprails/models/monitor_event_response"
|
|
@@ -69,5 +68,5 @@ require_relative "deeprails/models/monitor_update_params"
|
|
|
69
68
|
require_relative "deeprails/models/workflow_event_response"
|
|
70
69
|
require_relative "deeprails/models"
|
|
71
70
|
require_relative "deeprails/resources/defend"
|
|
72
|
-
require_relative "deeprails/resources/
|
|
71
|
+
require_relative "deeprails/resources/files"
|
|
73
72
|
require_relative "deeprails/resources/monitor"
|
data/rbi/deeprails/client.rbi
CHANGED
|
@@ -19,8 +19,8 @@ module Deeprails
|
|
|
19
19
|
sig { returns(Deeprails::Resources::Monitor) }
|
|
20
20
|
attr_reader :monitor
|
|
21
21
|
|
|
22
|
-
sig { returns(Deeprails::Resources::
|
|
23
|
-
attr_reader :
|
|
22
|
+
sig { returns(Deeprails::Resources::Files) }
|
|
23
|
+
attr_reader :files
|
|
24
24
|
|
|
25
25
|
# @api private
|
|
26
26
|
sig { override.returns(T::Hash[String, String]) }
|
|
@@ -85,6 +85,14 @@ module Deeprails
|
|
|
85
85
|
sig { params(description: String).void }
|
|
86
86
|
attr_writer :description
|
|
87
87
|
|
|
88
|
+
# An array of file IDs to search in the workflow's evaluations. Files must be
|
|
89
|
+
# uploaded via the DeepRails API first.
|
|
90
|
+
sig { returns(T.nilable(T::Array[String])) }
|
|
91
|
+
attr_reader :file_search
|
|
92
|
+
|
|
93
|
+
sig { params(file_search: T::Array[String]).void }
|
|
94
|
+
attr_writer :file_search
|
|
95
|
+
|
|
88
96
|
# Max. number of improvement action retries until a given event passes the
|
|
89
97
|
# guardrails. Defaults to 10.
|
|
90
98
|
sig { returns(T.nilable(Integer)) }
|
|
@@ -93,6 +101,13 @@ module Deeprails
|
|
|
93
101
|
sig { params(max_improvement_attempts: Integer).void }
|
|
94
102
|
attr_writer :max_improvement_attempts
|
|
95
103
|
|
|
104
|
+
# Whether to enable web search for this workflow's evaluations. Defaults to false.
|
|
105
|
+
sig { returns(T.nilable(T::Boolean)) }
|
|
106
|
+
attr_reader :web_search
|
|
107
|
+
|
|
108
|
+
sig { params(web_search: T::Boolean).void }
|
|
109
|
+
attr_writer :web_search
|
|
110
|
+
|
|
96
111
|
sig do
|
|
97
112
|
params(
|
|
98
113
|
improvement_action:
|
|
@@ -106,7 +121,9 @@ module Deeprails
|
|
|
106
121
|
],
|
|
107
122
|
custom_hallucination_threshold_values: T::Hash[Symbol, Float],
|
|
108
123
|
description: String,
|
|
124
|
+
file_search: T::Array[String],
|
|
109
125
|
max_improvement_attempts: Integer,
|
|
126
|
+
web_search: T::Boolean,
|
|
110
127
|
request_options: Deeprails::RequestOptions::OrHash
|
|
111
128
|
).returns(T.attached_class)
|
|
112
129
|
end
|
|
@@ -136,9 +153,14 @@ module Deeprails
|
|
|
136
153
|
custom_hallucination_threshold_values: nil,
|
|
137
154
|
# Description for the workflow.
|
|
138
155
|
description: nil,
|
|
156
|
+
# An array of file IDs to search in the workflow's evaluations. Files must be
|
|
157
|
+
# uploaded via the DeepRails API first.
|
|
158
|
+
file_search: nil,
|
|
139
159
|
# Max. number of improvement action retries until a given event passes the
|
|
140
160
|
# guardrails. Defaults to 10.
|
|
141
161
|
max_improvement_attempts: nil,
|
|
162
|
+
# Whether to enable web search for this workflow's evaluations. Defaults to false.
|
|
163
|
+
web_search: nil,
|
|
142
164
|
request_options: {}
|
|
143
165
|
)
|
|
144
166
|
end
|
|
@@ -157,7 +179,9 @@ module Deeprails
|
|
|
157
179
|
],
|
|
158
180
|
custom_hallucination_threshold_values: T::Hash[Symbol, Float],
|
|
159
181
|
description: String,
|
|
182
|
+
file_search: T::Array[String],
|
|
160
183
|
max_improvement_attempts: Integer,
|
|
184
|
+
web_search: T::Boolean,
|
|
161
185
|
request_options: Deeprails::RequestOptions
|
|
162
186
|
}
|
|
163
187
|
)
|