deeprails 0.18.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +62 -0
  3. data/README.md +1 -1
  4. data/lib/deeprails/internal/stream.rb +29 -0
  5. data/lib/deeprails/internal/transport/base_client.rb +3 -1
  6. data/lib/deeprails/internal/transport/pooled_net_requester.rb +12 -10
  7. data/lib/deeprails/internal/type/base_stream.rb +83 -0
  8. data/lib/deeprails/internal/util.rb +7 -2
  9. data/lib/deeprails/models/defend_create_workflow_params.rb +14 -1
  10. data/lib/deeprails/models/defend_response.rb +134 -10
  11. data/lib/deeprails/models/defend_submit_and_stream_event_params.rb +83 -0
  12. data/lib/deeprails/models/defend_submit_and_stream_event_response.rb +7 -0
  13. data/lib/deeprails/models/defend_submit_event_params.rb +52 -16
  14. data/lib/deeprails/models/defend_update_response.rb +9 -1
  15. data/lib/deeprails/models/defend_update_workflow_params.rb +131 -5
  16. data/lib/deeprails/models/monitor_create_params.rb +14 -1
  17. data/lib/deeprails/models/monitor_detail_response.rb +53 -14
  18. data/lib/deeprails/models/monitor_event_detail_response.rb +6 -2
  19. data/lib/deeprails/models/monitor_submit_event_params.rb +52 -16
  20. data/lib/deeprails/models/monitor_update_params.rb +46 -5
  21. data/lib/deeprails/models/workflow_event_detail_response.rb +88 -16
  22. data/lib/deeprails/models/workflow_event_response.rb +9 -1
  23. data/lib/deeprails/models.rb +2 -0
  24. data/lib/deeprails/resources/defend.rb +67 -4
  25. data/lib/deeprails/resources/monitor.rb +14 -6
  26. data/lib/deeprails/version.rb +1 -1
  27. data/lib/deeprails.rb +5 -0
  28. data/manifest.yaml +1 -0
  29. data/rbi/deeprails/internal/stream.rbi +20 -0
  30. data/rbi/deeprails/internal/transport/base_client.rbi +18 -2
  31. data/rbi/deeprails/internal/type/base_stream.rbi +75 -0
  32. data/rbi/deeprails/models/defend_create_workflow_params.rbi +21 -0
  33. data/rbi/deeprails/models/defend_response.rbi +286 -14
  34. data/rbi/deeprails/models/defend_submit_and_stream_event_params.rbi +148 -0
  35. data/rbi/deeprails/models/defend_submit_and_stream_event_response.rbi +7 -0
  36. data/rbi/deeprails/models/defend_submit_event_params.rbi +108 -25
  37. data/rbi/deeprails/models/defend_update_response.rbi +14 -3
  38. data/rbi/deeprails/models/defend_update_workflow_params.rbi +298 -4
  39. data/rbi/deeprails/models/monitor_create_params.rbi +21 -0
  40. data/rbi/deeprails/models/monitor_detail_response.rbi +103 -22
  41. data/rbi/deeprails/models/monitor_event_detail_response.rbi +4 -2
  42. data/rbi/deeprails/models/monitor_submit_event_params.rbi +108 -25
  43. data/rbi/deeprails/models/monitor_update_params.rbi +107 -4
  44. data/rbi/deeprails/models/workflow_event_detail_response.rbi +170 -24
  45. data/rbi/deeprails/models/workflow_event_response.rbi +8 -0
  46. data/rbi/deeprails/models.rbi +3 -0
  47. data/rbi/deeprails/resources/defend.rbi +96 -6
  48. data/rbi/deeprails/resources/monitor.rbi +28 -8
  49. data/sig/deeprails/internal/stream.rbs +9 -0
  50. data/sig/deeprails/internal/type/base_stream.rbs +38 -0
  51. data/sig/deeprails/models/defend_create_workflow_params.rbs +7 -0
  52. data/sig/deeprails/models/defend_response.rbs +114 -8
  53. data/sig/deeprails/models/defend_submit_and_stream_event_params.rbs +74 -0
  54. data/sig/deeprails/models/defend_submit_and_stream_event_response.rbs +5 -0
  55. data/sig/deeprails/models/defend_submit_event_params.rbs +39 -10
  56. data/sig/deeprails/models/defend_update_response.rbs +10 -3
  57. data/sig/deeprails/models/defend_update_workflow_params.rbs +103 -1
  58. data/sig/deeprails/models/monitor_create_params.rbs +7 -0
  59. data/sig/deeprails/models/monitor_detail_response.rbs +36 -9
  60. data/sig/deeprails/models/monitor_submit_event_params.rbs +39 -10
  61. data/sig/deeprails/models/monitor_update_params.rbs +45 -1
  62. data/sig/deeprails/models/workflow_event_detail_response.rbs +88 -15
  63. data/sig/deeprails/models/workflow_event_response.rbs +5 -0
  64. data/sig/deeprails/models.rbs +2 -0
  65. data/sig/deeprails/resources/defend.rbs +20 -0
  66. data/sig/deeprails/resources/monitor.rbs +4 -0
  67. metadata +28 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54176c43a05bdde5394a3f0f01c37c0f1485e5e29049174c0d480debcd6b5f04
4
- data.tar.gz: 8bd890ce30a2c75f3abc6e46261f7df60179bc4d2802a44db4eb27e1fb6e4bf7
3
+ metadata.gz: 27fa10a22615062a47a7c91fd063f80d87318da5d6bb5e375174fd9cb4b7e6b7
4
+ data.tar.gz: 24192097ccfe647482b666ece995279bc428774789bff6a62f678bb5da37356d
5
5
  SHA512:
6
- metadata.gz: 2ee61755f2763bbdf7b29e5a2c9f2890863c85e16e5a32175251360f21ccb6128c1af96ac04feb026c00ee19ad0a5fc631c382e9a8a91c0af7e1cb485795093e
7
- data.tar.gz: 1509a75d3b7a7565fe47ab1cb831de2445eaa8c08769b78f3d66d13ab9530752d8b1d41898d495b77aac678e4d7aaac59c58bde46a491bff8ea036bc2cca5826
6
+ metadata.gz: 1648800bce667593e627487f6f46b9a70d5958327d002178b9cd84f330e8399d37709774488bec9e84402afc1b9553c7512497eb31237c570e4cf55f1563ec36
7
+ data.tar.gz: 37dc7effa1649426ac95e881aafc84fed9b7c1dad3490969a8c4e9df6ad575ff54b7b37f21d98df82cdab0c7210cb02e86f54ab6cb261a9e50b6b15af5783cc0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,67 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.23.0 (2026-01-20)
4
+
5
+ Full Changelog: [v0.22.0...v0.23.0](https://github.com/deeprails/deeprails-ruby-sdk/compare/v0.22.0...v0.23.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** manual updates ([dbfbe16](https://github.com/deeprails/deeprails-ruby-sdk/commit/dbfbe16ac8b8bef8066b3a1b12ffc1d1b6e793d3))
10
+
11
+
12
+ ### Chores
13
+
14
+ * **internal:** codegen related update ([3cae355](https://github.com/deeprails/deeprails-ruby-sdk/commit/3cae35599062af95a670c3bb23ab52ee5ccb5fe6))
15
+ * **internal:** codegen related update ([cbd8b12](https://github.com/deeprails/deeprails-ruby-sdk/commit/cbd8b12f0ddfd8f0ec1e15930095ede2a5bc1fe1))
16
+ * **internal:** update `actions/checkout` version ([b24ab56](https://github.com/deeprails/deeprails-ruby-sdk/commit/b24ab5603ff3fc351e833ecc41522c6a4065908e))
17
+
18
+ ## 0.22.0 (2025-12-23)
19
+
20
+ Full Changelog: [v0.21.0...v0.22.0](https://github.com/deeprails/deeprails-ruby-sdk/compare/v0.21.0...v0.22.0)
21
+
22
+ ### Features
23
+
24
+ * **api:** add key improvements and analysis of failures ([8cc372b](https://github.com/deeprails/deeprails-ruby-sdk/commit/8cc372b0f1cf6b6c7d5f55b6f90d3a27ac74b76c))
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * calling `break` out of streams should be instantaneous ([5f7ac38](https://github.com/deeprails/deeprails-ruby-sdk/commit/5f7ac38fa7016361c356072867dc3a025b3c3a92))
30
+ * issue where json.parse errors when receiving HTTP 204 with nobody ([f7b4a02](https://github.com/deeprails/deeprails-ruby-sdk/commit/f7b4a026be2ddc89a52eedc4643c7e2e51f76e5d))
31
+
32
+ ## 0.21.0 (2025-12-15)
33
+
34
+ Full Changelog: [v0.20.0...v0.21.0](https://github.com/deeprails/deeprails-ruby-sdk/compare/v0.20.0...v0.21.0)
35
+
36
+ ### Features
37
+
38
+ * **api:** add precision plus codex ([d67ca44](https://github.com/deeprails/deeprails-ruby-sdk/commit/d67ca4443d30fad4211caf43f0d7a63adf4f8b2b))
39
+
40
+ ## 0.20.0 (2025-12-07)
41
+
42
+ Full Changelog: [v0.19.0...v0.20.0](https://github.com/deeprails/deeprails-ruby-sdk/compare/v0.19.0...v0.20.0)
43
+
44
+ ### Features
45
+
46
+ * **api:** Expand update endpoints ([faaf87b](https://github.com/deeprails/deeprails-ruby-sdk/commit/faaf87bc835773fe50e20c43a8ca59b69f4d3b2e))
47
+ * **api:** manual updates ([b8a55ea](https://github.com/deeprails/deeprails-ruby-sdk/commit/b8a55eafa68bed34063f8745a8d460266d1a30d1))
48
+
49
+ ## 0.19.0 (2025-12-07)
50
+
51
+ Full Changelog: [v0.18.1...v0.19.0](https://github.com/deeprails/deeprails-ruby-sdk/compare/v0.18.1...v0.19.0)
52
+
53
+ ### Features
54
+
55
+ * **api:** added context_awareness and context ([9562c79](https://github.com/deeprails/deeprails-ruby-sdk/commit/9562c797fdfd5fdb45b28a4b428b005017998c55))
56
+
57
+ ## 0.18.1 (2025-11-21)
58
+
59
+ Full Changelog: [v0.18.0...v0.18.1](https://github.com/deeprails/deeprails-ruby-sdk/compare/v0.18.0...v0.18.1)
60
+
61
+ ### Chores
62
+
63
+ * explicitly require "base64" gem ([99d2fb5](https://github.com/deeprails/deeprails-ruby-sdk/commit/99d2fb51770004bb14a8f15370956852481eb233))
64
+
3
65
  ## 0.18.0 (2025-11-20)
4
66
 
5
67
  Full Changelog: [v0.17.0...v0.18.0](https://github.com/deeprails/deeprails-ruby-sdk/compare/v0.17.0...v0.18.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.0"
18
+ gem "deeprails", "~> 0.23.0"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Deeprails
4
+ module Internal
5
+ # @generic Elem
6
+ #
7
+ # @example
8
+ # stream.each do |event|
9
+ # puts(event)
10
+ # end
11
+ class Stream
12
+ include Deeprails::Internal::Type::BaseStream
13
+
14
+ # @api private
15
+ #
16
+ # @return [Enumerable<generic<Elem>>]
17
+ private def iterator
18
+ @iterator ||= Deeprails::Internal::Util.chain_fused(@stream) do |y|
19
+ @stream.each do |msg|
20
+ next if (data = msg.fetch(:data)).nil?
21
+ decoded = JSON.parse(data, symbolize_names: true)
22
+ unwrapped = Deeprails::Internal::Util.dig(decoded, @unwrap)
23
+ y << Deeprails::Internal::Type::Converter.coerce(@model, unwrapped)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -549,7 +549,9 @@ module Deeprails
549
549
  )
550
550
  ),
551
551
  page: T.nilable(T::Class[Deeprails::Internal::Type::BasePage[Deeprails::Internal::Type::BaseModel]]),
552
- stream: T.nilable(T::Class[T.anything]),
552
+ stream: T.nilable(
553
+ T::Class[Deeprails::Internal::Type::BaseStream[T.anything, Deeprails::Internal::Type::BaseModel]]
554
+ ),
553
555
  model: T.nilable(Deeprails::Internal::Type::Converter::Input),
554
556
  options: T.nilable(Deeprails::RequestOptions::OrHash)
555
557
  }
@@ -153,17 +153,19 @@ module Deeprails
153
153
  end
154
154
 
155
155
  self.class.calibrate_socket_timeout(conn, deadline)
156
- conn.request(req) do |rsp|
157
- y << [req, rsp]
158
- break if finished
159
-
160
- rsp.read_body do |bytes|
161
- y << bytes.force_encoding(Encoding::BINARY)
162
- break if finished
163
-
164
- self.class.calibrate_socket_timeout(conn, deadline)
156
+ ::Kernel.catch(:jump) do
157
+ conn.request(req) do |rsp|
158
+ y << [req, rsp]
159
+ ::Kernel.throw(:jump) if finished
160
+
161
+ rsp.read_body do |bytes|
162
+ y << bytes.force_encoding(Encoding::BINARY)
163
+ ::Kernel.throw(:jump) if finished
164
+
165
+ self.class.calibrate_socket_timeout(conn, deadline)
166
+ end
167
+ eof = true
165
168
  end
166
- eof = true
167
169
  end
168
170
  end
169
171
  ensure
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Deeprails
4
+ module Internal
5
+ module Type
6
+ # @api private
7
+ #
8
+ # @generic Elem
9
+ #
10
+ # This module provides a base implementation for streaming responses in the SDK.
11
+ #
12
+ # @see https://rubyapi.org/3.2/o/enumerable
13
+ module BaseStream
14
+ include Enumerable
15
+
16
+ # @return [Integer]
17
+ attr_reader :status
18
+
19
+ # @return [Hash{String=>String}]
20
+ attr_reader :headers
21
+
22
+ # @api public
23
+ #
24
+ # @return [void]
25
+ def close = Deeprails::Internal::Util.close_fused!(@iterator)
26
+
27
+ # @api private
28
+ #
29
+ # @return [Enumerable<generic<Elem>>]
30
+ private def iterator = (raise NotImplementedError)
31
+
32
+ # @api public
33
+ #
34
+ # @param blk [Proc]
35
+ #
36
+ # @yieldparam [generic<Elem>]
37
+ # @return [void]
38
+ def each(&blk)
39
+ unless block_given?
40
+ raise ArgumentError.new("A block must be given to ##{__method__}")
41
+ end
42
+ @iterator.each(&blk)
43
+ end
44
+
45
+ # @api public
46
+ #
47
+ # @return [Enumerator<generic<Elem>>]
48
+ def to_enum = @iterator
49
+
50
+ alias_method :enum_for, :to_enum
51
+
52
+ # @api private
53
+ #
54
+ # @param model [Class, Deeprails::Internal::Type::Converter]
55
+ # @param url [URI::Generic]
56
+ # @param status [Integer]
57
+ # @param headers [Hash{String=>String}]
58
+ # @param response [Net::HTTPResponse]
59
+ # @param unwrap [Symbol, Integer, Array<Symbol, Integer>, Proc]
60
+ # @param stream [Enumerable<Object>]
61
+ def initialize(model:, url:, status:, headers:, response:, unwrap:, stream:)
62
+ @model = model
63
+ @url = url
64
+ @status = status
65
+ @headers = headers
66
+ @response = response
67
+ @unwrap = unwrap
68
+ @stream = stream
69
+ @iterator = iterator
70
+ end
71
+
72
+ # @api private
73
+ #
74
+ # @return [String]
75
+ def inspect
76
+ model = Deeprails::Internal::Type::Converter.inspect(@model, depth: 1)
77
+
78
+ "#<#{self.class}[#{model}]:0x#{object_id.to_s(16)}>"
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -657,7 +657,8 @@ module Deeprails
657
657
  def decode_content(headers, stream:, suppress_error: false)
658
658
  case (content_type = headers["content-type"])
659
659
  in Deeprails::Internal::Util::JSON_CONTENT
660
- json = stream.to_a.join
660
+ return nil if (json = stream.to_a.join).empty?
661
+
661
662
  begin
662
663
  JSON.parse(json, symbolize_names: true)
663
664
  rescue JSON::ParserError => e
@@ -667,7 +668,11 @@ module Deeprails
667
668
  in Deeprails::Internal::Util::JSONL_CONTENT
668
669
  lines = decode_lines(stream)
669
670
  chain_fused(lines) do |y|
670
- lines.each { y << JSON.parse(_1, symbolize_names: true) }
671
+ lines.each do
672
+ next if _1.empty?
673
+
674
+ y << JSON.parse(_1, symbolize_names: true)
675
+ end
671
676
  end
672
677
  in %r{^text/event-stream}
673
678
  lines = decode_lines(stream)
@@ -43,6 +43,17 @@ module Deeprails
43
43
  optional :automatic_hallucination_tolerance_levels,
44
44
  -> { Deeprails::Internal::Type::HashOf[enum: Deeprails::DefendCreateWorkflowParams::AutomaticHallucinationToleranceLevel] }
45
45
 
46
+ # @!attribute context_awareness
47
+ # Context includes any structured information that directly relates to the model’s
48
+ # input and expected output—e.g., the recent turn-by-turn history between an AI
49
+ # tutor and a student, facts or state passed through an agentic workflow, or other
50
+ # domain-specific signals your system already knows and wants the model to
51
+ # condition on. This field determines whether to enable context awareness for this
52
+ # workflow's evaluations. Defaults to false.
53
+ #
54
+ # @return [Boolean, nil]
55
+ optional :context_awareness, Deeprails::Internal::Type::Boolean
56
+
46
57
  # @!attribute custom_hallucination_threshold_values
47
58
  # Mapping of guardrail metrics to floating point threshold values. Possible
48
59
  # metrics are `correctness`, `completeness`, `instruction_adherence`,
@@ -77,7 +88,7 @@ module Deeprails
77
88
  # @return [Boolean, nil]
78
89
  optional :web_search, Deeprails::Internal::Type::Boolean
79
90
 
80
- # @!method initialize(improvement_action:, name:, threshold_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: {})
91
+ # @!method initialize(improvement_action:, name:, threshold_type:, automatic_hallucination_tolerance_levels: nil, context_awareness: nil, custom_hallucination_threshold_values: nil, description: nil, file_search: nil, max_improvement_attempts: nil, web_search: nil, request_options: {})
81
92
  # Some parameter documentations has been truncated, see
82
93
  # {Deeprails::Models::DefendCreateWorkflowParams} for more details.
83
94
  #
@@ -89,6 +100,8 @@ module Deeprails
89
100
  #
90
101
  # @param automatic_hallucination_tolerance_levels [Hash{Symbol=>Symbol, Deeprails::Models::DefendCreateWorkflowParams::AutomaticHallucinationToleranceLevel}] Mapping of guardrail metrics to hallucination tolerance levels
91
102
  #
103
+ # @param context_awareness [Boolean] Context includes any structured information that directly relates to the model’s
104
+ #
92
105
  # @param custom_hallucination_threshold_values [Hash{Symbol=>Float}] Mapping of guardrail metrics to floating point threshold values. Possible metric
93
106
  #
94
107
  # @param description [String] Description for the workflow.
@@ -13,8 +13,8 @@ module Deeprails
13
13
  -> { Deeprails::Internal::Type::HashOf[enum: Deeprails::DefendResponse::AutomaticHallucinationToleranceLevel] }
14
14
 
15
15
  # @!attribute capabilities
16
- # Extended AI capabilities available to the event, if any. Can be `web_search`
17
- # and/or `file_search`.
16
+ # Extended AI capabilities available to the event, if any. Can be `web_search`,
17
+ # `file_search`, and/or `context_awareness`.
18
18
  #
19
19
  # @return [Array<Deeprails::Models::DefendResponse::Capability>]
20
20
  required :capabilities, -> { Deeprails::Internal::Type::ArrayOf[Deeprails::DefendResponse::Capability] }
@@ -101,7 +101,7 @@ module Deeprails
101
101
  #
102
102
  # @param automatic_hallucination_tolerance_levels [Hash{Symbol=>Symbol, Deeprails::Models::DefendResponse::AutomaticHallucinationToleranceLevel}] Mapping of guardrail metric names to tolerance values. Values can be strings (`l
103
103
  #
104
- # @param capabilities [Array<Deeprails::Models::DefendResponse::Capability>] Extended AI capabilities available to the event, if any. Can be `web_search` and
104
+ # @param capabilities [Array<Deeprails::Models::DefendResponse::Capability>] Extended AI capabilities available to the event, if any. Can be `web_search`, `f
105
105
  #
106
106
  # @param created_at [Time] The time the workflow was created in UTC.
107
107
  #
@@ -149,6 +149,12 @@ module Deeprails
149
149
  end
150
150
 
151
151
  class Event < Deeprails::Internal::Type::BaseModel
152
+ # @!attribute billing_request_id
153
+ # The ID of the billing request for the event.
154
+ #
155
+ # @return [String, nil]
156
+ optional :billing_request_id, String
157
+
152
158
  # @!attribute evaluations
153
159
  # An array of evaluations for this event.
154
160
  #
@@ -169,21 +175,46 @@ module Deeprails
169
175
  optional :improved_model_output, String
170
176
 
171
177
  # @!attribute improvement_tool_status
172
- # Status of the improvement tool used to improve the event.
178
+ # Status of the improvement tool used to improve the event. `improvement_required`
179
+ # indicates that the evaluation is complete and the improvement action is needed
180
+ # but is not taking place. `improved` and `improvement_failed` indicate when the
181
+ # improvement action concludes, successfully and unsuccessfully, respectively.
182
+ # `no_improvement_required` means that the first evaluation passed all its
183
+ # metrics!
173
184
  #
174
- # @return [String, nil]
175
- optional :improvement_tool_status, String
185
+ # @return [Symbol, Deeprails::Models::DefendResponse::Event::ImprovementToolStatus, nil]
186
+ optional :improvement_tool_status, enum: -> { Deeprails::DefendResponse::Event::ImprovementToolStatus }
187
+
188
+ # @!attribute status
189
+ # Status of the event.
190
+ #
191
+ # @return [Symbol, Deeprails::Models::DefendResponse::Event::Status, nil]
192
+ optional :status, enum: -> { Deeprails::DefendResponse::Event::Status }
176
193
 
177
- # @!method initialize(evaluations: nil, event_id: nil, improved_model_output: nil, improvement_tool_status: nil)
194
+ # @!method initialize(billing_request_id: nil, evaluations: nil, event_id: nil, improved_model_output: nil, improvement_tool_status: nil, status: nil)
195
+ # Some parameter documentations has been truncated, see
196
+ # {Deeprails::Models::DefendResponse::Event} for more details.
197
+ #
198
+ # @param billing_request_id [String] The ID of the billing request for the event.
199
+ #
178
200
  # @param evaluations [Array<Deeprails::Models::DefendResponse::Event::Evaluation>] An array of evaluations for this event.
179
201
  #
180
202
  # @param event_id [String] A unique workflow event ID.
181
203
  #
182
204
  # @param improved_model_output [String] Improved model output after improvement tool was applied.
183
205
  #
184
- # @param improvement_tool_status [String] Status of the improvement tool used to improve the event.
206
+ # @param improvement_tool_status [Symbol, Deeprails::Models::DefendResponse::Event::ImprovementToolStatus] Status of the improvement tool used to improve the event. `improvement_required`
207
+ #
208
+ # @param status [Symbol, Deeprails::Models::DefendResponse::Event::Status] Status of the event.
185
209
 
186
210
  class Evaluation < Deeprails::Internal::Type::BaseModel
211
+ # @!attribute analysis_of_failures
212
+ # Analysis of the failures of the model_output according to the guardrail metrics
213
+ # evaluated.
214
+ #
215
+ # @return [String, nil]
216
+ optional :analysis_of_failures, String
217
+
187
218
  # @!attribute attempt
188
219
  # The attempt number or identifier for this evaluation.
189
220
  #
@@ -226,6 +257,24 @@ module Deeprails
226
257
  # @return [Array<String>, nil]
227
258
  optional :guardrail_metrics, Deeprails::Internal::Type::ArrayOf[String]
228
259
 
260
+ # @!attribute improvement_tool_status
261
+ # Status of the improvement tool used to improve the event. `improvement_required`
262
+ # indicates that the evaluation is complete and the improvement action is needed
263
+ # but is not taking place. `improved` and `improvement_failed` indicate when the
264
+ # improvement action concludes, successfully and unsuccessfully, respectively.
265
+ # `no_improvement_required` means that the first evaluation passed all its
266
+ # metrics!
267
+ #
268
+ # @return [Symbol, Deeprails::Models::DefendResponse::Event::Evaluation::ImprovementToolStatus, nil]
269
+ optional :improvement_tool_status,
270
+ enum: -> { Deeprails::DefendResponse::Event::Evaluation::ImprovementToolStatus }
271
+
272
+ # @!attribute key_improvements
273
+ # A list of key improvements made to the model_output to address the failures.
274
+ #
275
+ # @return [Array<String>, nil]
276
+ optional :key_improvements, Deeprails::Internal::Type::ArrayOf[String]
277
+
229
278
  # @!attribute model_input
230
279
  # The model input used for the evaluation.
231
280
  #
@@ -262,7 +311,12 @@ module Deeprails
262
311
  # @return [String, nil]
263
312
  optional :run_mode, String
264
313
 
265
- # @!method initialize(attempt: nil, created_at: nil, error_message: nil, evaluation_result: nil, evaluation_status: nil, evaluation_total_cost: nil, guardrail_metrics: nil, model_input: nil, model_output: nil, modified_at: nil, nametag: nil, progress: nil, run_mode: nil)
314
+ # @!method initialize(analysis_of_failures: nil, attempt: nil, created_at: nil, error_message: nil, evaluation_result: nil, evaluation_status: nil, evaluation_total_cost: nil, guardrail_metrics: nil, improvement_tool_status: nil, key_improvements: nil, model_input: nil, model_output: nil, modified_at: nil, nametag: nil, progress: nil, run_mode: nil)
315
+ # Some parameter documentations has been truncated, see
316
+ # {Deeprails::Models::DefendResponse::Event::Evaluation} for more details.
317
+ #
318
+ # @param analysis_of_failures [String] Analysis of the failures of the model_output according to the guardrail metrics
319
+ #
266
320
  # @param attempt [String] The attempt number or identifier for this evaluation.
267
321
  #
268
322
  # @param created_at [Time] The time the evaluation was created in UTC.
@@ -277,6 +331,10 @@ module Deeprails
277
331
  #
278
332
  # @param guardrail_metrics [Array<String>] An array of guardrail metrics evaluated.
279
333
  #
334
+ # @param improvement_tool_status [Symbol, Deeprails::Models::DefendResponse::Event::Evaluation::ImprovementToolStatus] Status of the improvement tool used to improve the event. `improvement_required`
335
+ #
336
+ # @param key_improvements [Array<String>] A list of key improvements made to the model_output to address the failures.
337
+ #
280
338
  # @param model_input [Hash{Symbol=>Object}] The model input used for the evaluation.
281
339
  #
282
340
  # @param model_output [String] The model output that was evaluated.
@@ -288,6 +346,60 @@ module Deeprails
288
346
  # @param progress [Integer] Evaluation progress (0-100).
289
347
  #
290
348
  # @param run_mode [String] Run mode used for the evaluation.
349
+
350
+ # Status of the improvement tool used to improve the event. `improvement_required`
351
+ # indicates that the evaluation is complete and the improvement action is needed
352
+ # but is not taking place. `improved` and `improvement_failed` indicate when the
353
+ # improvement action concludes, successfully and unsuccessfully, respectively.
354
+ # `no_improvement_required` means that the first evaluation passed all its
355
+ # metrics!
356
+ #
357
+ # @see Deeprails::Models::DefendResponse::Event::Evaluation#improvement_tool_status
358
+ module ImprovementToolStatus
359
+ extend Deeprails::Internal::Type::Enum
360
+
361
+ IMPROVED = :improved
362
+ IMPROVEMENT_FAILED = :improvement_failed
363
+ NO_IMPROVEMENT_REQUIRED = :no_improvement_required
364
+ IMPROVEMENT_REQUIRED = :improvement_required
365
+
366
+ # @!method self.values
367
+ # @return [Array<Symbol>]
368
+ end
369
+ end
370
+
371
+ # Status of the improvement tool used to improve the event. `improvement_required`
372
+ # indicates that the evaluation is complete and the improvement action is needed
373
+ # but is not taking place. `improved` and `improvement_failed` indicate when the
374
+ # improvement action concludes, successfully and unsuccessfully, respectively.
375
+ # `no_improvement_required` means that the first evaluation passed all its
376
+ # metrics!
377
+ #
378
+ # @see Deeprails::Models::DefendResponse::Event#improvement_tool_status
379
+ module ImprovementToolStatus
380
+ extend Deeprails::Internal::Type::Enum
381
+
382
+ IMPROVED = :improved
383
+ IMPROVEMENT_FAILED = :improvement_failed
384
+ NO_IMPROVEMENT_REQUIRED = :no_improvement_required
385
+ IMPROVEMENT_REQUIRED = :improvement_required
386
+
387
+ # @!method self.values
388
+ # @return [Array<Symbol>]
389
+ end
390
+
391
+ # Status of the event.
392
+ #
393
+ # @see Deeprails::Models::DefendResponse::Event#status
394
+ module Status
395
+ extend Deeprails::Internal::Type::Enum
396
+
397
+ COMPLETED = :completed
398
+ FAILED = :failed
399
+ IN_PROGRESS = :in_progress
400
+
401
+ # @!method self.values
402
+ # @return [Array<Symbol>]
291
403
  end
292
404
  end
293
405
 
@@ -307,10 +419,22 @@ module Deeprails
307
419
  # @return [Integer, nil]
308
420
  optional :file_size, Integer
309
421
 
310
- # @!method initialize(file_id: nil, file_name: nil, file_size: nil)
422
+ # @!attribute presigned_url
423
+ #
424
+ # @return [String, nil]
425
+ optional :presigned_url, String
426
+
427
+ # @!attribute presigned_url_expires_at
428
+ #
429
+ # @return [Time, nil]
430
+ optional :presigned_url_expires_at, Time
431
+
432
+ # @!method initialize(file_id: nil, file_name: nil, file_size: nil, presigned_url: nil, presigned_url_expires_at: nil)
311
433
  # @param file_id [String]
312
434
  # @param file_name [String]
313
435
  # @param file_size [Integer]
436
+ # @param presigned_url [String]
437
+ # @param presigned_url_expires_at [Time]
314
438
  end
315
439
 
316
440
  # Status of the selected workflow. May be `inactive` or `active`. Inactive
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Deeprails
4
+ module Models
5
+ # @see Deeprails::Resources::Defend#submit_and_stream_event_streaming
6
+ class DefendSubmitAndStreamEventParams < Deeprails::Internal::Type::BaseModel
7
+ extend Deeprails::Internal::Type::RequestParameters::Converter
8
+ include Deeprails::Internal::Type::RequestParameters
9
+
10
+ # @!attribute model_input
11
+ # The input provided to the model (e.g., prompt, messages).
12
+ #
13
+ # @return [Hash{Symbol=>Object}]
14
+ required :model_input, Deeprails::Internal::Type::HashOf[Deeprails::Internal::Type::Unknown]
15
+
16
+ # @!attribute model_output
17
+ # The output generated by the model to be evaluated.
18
+ #
19
+ # @return [String]
20
+ required :model_output, String
21
+
22
+ # @!attribute model_used
23
+ # The model that generated the output (e.g., "gpt-4", "claude-3").
24
+ #
25
+ # @return [String]
26
+ required :model_used, String
27
+
28
+ # @!attribute run_mode
29
+ # The evaluation run mode. Streaming only supports fast, precision, and
30
+ # precision_codex.
31
+ #
32
+ # @return [Symbol, Deeprails::Models::DefendSubmitAndStreamEventParams::RunMode]
33
+ required :run_mode, enum: -> { Deeprails::DefendSubmitAndStreamEventParams::RunMode }
34
+
35
+ # @!attribute stream
36
+ # Enable SSE streaming for real-time token feedback. Only supported for
37
+ # single-model run modes (fast, precision, precision_codex).
38
+ #
39
+ # @return [Boolean, nil]
40
+ optional :stream, Deeprails::Internal::Type::Boolean
41
+
42
+ # @!attribute nametag
43
+ # Optional tag to identify this event.
44
+ #
45
+ # @return [String, nil]
46
+ optional :nametag, String
47
+
48
+ # @!method initialize(model_input:, model_output:, model_used:, run_mode:, stream: nil, nametag: nil, request_options: {})
49
+ # Some parameter documentations has been truncated, see
50
+ # {Deeprails::Models::DefendSubmitAndStreamEventParams} for more details.
51
+ #
52
+ # @param model_input [Hash{Symbol=>Object}] The input provided to the model (e.g., prompt, messages).
53
+ #
54
+ # @param model_output [String] The output generated by the model to be evaluated.
55
+ #
56
+ # @param model_used [String] The model that generated the output (e.g., "gpt-4", "claude-3").
57
+ #
58
+ # @param run_mode [Symbol, Deeprails::Models::DefendSubmitAndStreamEventParams::RunMode] The evaluation run mode. Streaming only supports fast, precision, and
59
+ # precision\_
60
+ #
61
+ # @param stream [Boolean] Enable SSE streaming for real-time token feedback. Only supported for single-mod
62
+ #
63
+ # @param nametag [String] Optional tag to identify this event.
64
+ #
65
+ # @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}]
66
+
67
+ # The evaluation run mode. Streaming only supports fast, precision, and
68
+ # precision_codex.
69
+ module RunMode
70
+ extend Deeprails::Internal::Type::Enum
71
+
72
+ FAST = :fast
73
+ PRECISION = :precision
74
+ PRECISION_CODEX = :precision_codex
75
+ PRECISION_MAX = :precision_max
76
+ PRECISION_MAX_CODEX = :precision_max_codex
77
+
78
+ # @!method self.values
79
+ # @return [Array<Symbol>]
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Deeprails
4
+ module Models
5
+ DefendSubmitAndStreamEventResponse = String
6
+ end
7
+ end