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.
Files changed (131) hide show
  1. checksums.yaml +7 -0
  2. data/.ignore +2 -0
  3. data/CHANGELOG.md +18 -0
  4. data/README.md +273 -0
  5. data/SECURITY.md +27 -0
  6. data/lib/deeprails/client.rb +82 -0
  7. data/lib/deeprails/errors.rb +228 -0
  8. data/lib/deeprails/file_part.rb +58 -0
  9. data/lib/deeprails/internal/transport/base_client.rb +567 -0
  10. data/lib/deeprails/internal/transport/pooled_net_requester.rb +198 -0
  11. data/lib/deeprails/internal/type/array_of.rb +168 -0
  12. data/lib/deeprails/internal/type/base_model.rb +531 -0
  13. data/lib/deeprails/internal/type/base_page.rb +55 -0
  14. data/lib/deeprails/internal/type/boolean.rb +77 -0
  15. data/lib/deeprails/internal/type/converter.rb +327 -0
  16. data/lib/deeprails/internal/type/enum.rb +131 -0
  17. data/lib/deeprails/internal/type/file_input.rb +111 -0
  18. data/lib/deeprails/internal/type/hash_of.rb +188 -0
  19. data/lib/deeprails/internal/type/request_parameters.rb +42 -0
  20. data/lib/deeprails/internal/type/union.rb +237 -0
  21. data/lib/deeprails/internal/type/unknown.rb +81 -0
  22. data/lib/deeprails/internal/util.rb +915 -0
  23. data/lib/deeprails/internal.rb +20 -0
  24. data/lib/deeprails/models/api_response.rb +119 -0
  25. data/lib/deeprails/models/defend_create_workflow_params.rb +132 -0
  26. data/lib/deeprails/models/defend_response.rb +123 -0
  27. data/lib/deeprails/models/defend_retrieve_event_params.rb +20 -0
  28. data/lib/deeprails/models/defend_retrieve_workflow_params.rb +14 -0
  29. data/lib/deeprails/models/defend_submit_event_params.rb +98 -0
  30. data/lib/deeprails/models/defend_update_workflow_params.rb +49 -0
  31. data/lib/deeprails/models/evaluate_create_params.rb +123 -0
  32. data/lib/deeprails/models/evaluate_retrieve_params.rb +14 -0
  33. data/lib/deeprails/models/evaluation.rb +225 -0
  34. data/lib/deeprails/models/monitor_create_params.rb +30 -0
  35. data/lib/deeprails/models/monitor_retrieve_params.rb +22 -0
  36. data/lib/deeprails/models/monitor_retrieve_response.rb +186 -0
  37. data/lib/deeprails/models/monitor_submit_event_params.rb +124 -0
  38. data/lib/deeprails/models/monitor_submit_event_response.rb +77 -0
  39. data/lib/deeprails/models/monitor_update_params.rb +54 -0
  40. data/lib/deeprails/models/workflow_event_response.rb +57 -0
  41. data/lib/deeprails/models.rb +71 -0
  42. data/lib/deeprails/request_options.rb +77 -0
  43. data/lib/deeprails/resources/defend.rb +162 -0
  44. data/lib/deeprails/resources/evaluate.rb +70 -0
  45. data/lib/deeprails/resources/monitor.rb +130 -0
  46. data/lib/deeprails/version.rb +5 -0
  47. data/lib/deeprails.rb +73 -0
  48. data/manifest.yaml +15 -0
  49. data/rbi/deeprails/client.rbi +55 -0
  50. data/rbi/deeprails/errors.rbi +205 -0
  51. data/rbi/deeprails/file_part.rbi +37 -0
  52. data/rbi/deeprails/internal/transport/base_client.rbi +293 -0
  53. data/rbi/deeprails/internal/transport/pooled_net_requester.rbi +79 -0
  54. data/rbi/deeprails/internal/type/array_of.rbi +104 -0
  55. data/rbi/deeprails/internal/type/base_model.rbi +304 -0
  56. data/rbi/deeprails/internal/type/base_page.rbi +42 -0
  57. data/rbi/deeprails/internal/type/boolean.rbi +58 -0
  58. data/rbi/deeprails/internal/type/converter.rbi +216 -0
  59. data/rbi/deeprails/internal/type/enum.rbi +82 -0
  60. data/rbi/deeprails/internal/type/file_input.rbi +59 -0
  61. data/rbi/deeprails/internal/type/hash_of.rbi +104 -0
  62. data/rbi/deeprails/internal/type/request_parameters.rbi +29 -0
  63. data/rbi/deeprails/internal/type/union.rbi +128 -0
  64. data/rbi/deeprails/internal/type/unknown.rbi +58 -0
  65. data/rbi/deeprails/internal/util.rbi +487 -0
  66. data/rbi/deeprails/internal.rbi +18 -0
  67. data/rbi/deeprails/models/api_response.rbi +204 -0
  68. data/rbi/deeprails/models/defend_create_workflow_params.rbi +270 -0
  69. data/rbi/deeprails/models/defend_response.rbi +198 -0
  70. data/rbi/deeprails/models/defend_retrieve_event_params.rbi +38 -0
  71. data/rbi/deeprails/models/defend_retrieve_workflow_params.rbi +30 -0
  72. data/rbi/deeprails/models/defend_submit_event_params.rbi +170 -0
  73. data/rbi/deeprails/models/defend_update_workflow_params.rbi +107 -0
  74. data/rbi/deeprails/models/evaluate_create_params.rbi +253 -0
  75. data/rbi/deeprails/models/evaluate_retrieve_params.rbi +27 -0
  76. data/rbi/deeprails/models/evaluation.rbi +382 -0
  77. data/rbi/deeprails/models/monitor_create_params.rbi +54 -0
  78. data/rbi/deeprails/models/monitor_retrieve_params.rbi +43 -0
  79. data/rbi/deeprails/models/monitor_retrieve_response.rbi +336 -0
  80. data/rbi/deeprails/models/monitor_submit_event_params.rbi +264 -0
  81. data/rbi/deeprails/models/monitor_submit_event_response.rbi +134 -0
  82. data/rbi/deeprails/models/monitor_update_params.rbi +114 -0
  83. data/rbi/deeprails/models/workflow_event_response.rbi +85 -0
  84. data/rbi/deeprails/models.rbi +33 -0
  85. data/rbi/deeprails/request_options.rbi +59 -0
  86. data/rbi/deeprails/resources/defend.rbi +151 -0
  87. data/rbi/deeprails/resources/evaluate.rbi +66 -0
  88. data/rbi/deeprails/resources/monitor.rbi +114 -0
  89. data/rbi/deeprails/version.rbi +5 -0
  90. data/sig/deeprails/client.rbs +30 -0
  91. data/sig/deeprails/errors.rbs +117 -0
  92. data/sig/deeprails/file_part.rbs +21 -0
  93. data/sig/deeprails/internal/transport/base_client.rbs +131 -0
  94. data/sig/deeprails/internal/transport/pooled_net_requester.rbs +45 -0
  95. data/sig/deeprails/internal/type/array_of.rbs +48 -0
  96. data/sig/deeprails/internal/type/base_model.rbs +102 -0
  97. data/sig/deeprails/internal/type/base_page.rbs +24 -0
  98. data/sig/deeprails/internal/type/boolean.rbs +26 -0
  99. data/sig/deeprails/internal/type/converter.rbs +79 -0
  100. data/sig/deeprails/internal/type/enum.rbs +32 -0
  101. data/sig/deeprails/internal/type/file_input.rbs +25 -0
  102. data/sig/deeprails/internal/type/hash_of.rbs +48 -0
  103. data/sig/deeprails/internal/type/request_parameters.rbs +19 -0
  104. data/sig/deeprails/internal/type/union.rbs +52 -0
  105. data/sig/deeprails/internal/type/unknown.rbs +26 -0
  106. data/sig/deeprails/internal/util.rbs +185 -0
  107. data/sig/deeprails/internal.rbs +9 -0
  108. data/sig/deeprails/models/api_response.rbs +100 -0
  109. data/sig/deeprails/models/defend_create_workflow_params.rbs +98 -0
  110. data/sig/deeprails/models/defend_response.rbs +96 -0
  111. data/sig/deeprails/models/defend_retrieve_event_params.rbs +23 -0
  112. data/sig/deeprails/models/defend_retrieve_workflow_params.rbs +15 -0
  113. data/sig/deeprails/models/defend_submit_event_params.rbs +73 -0
  114. data/sig/deeprails/models/defend_update_workflow_params.rbs +55 -0
  115. data/sig/deeprails/models/evaluate_create_params.rbs +107 -0
  116. data/sig/deeprails/models/evaluate_retrieve_params.rbs +15 -0
  117. data/sig/deeprails/models/evaluation.rbs +189 -0
  118. data/sig/deeprails/models/monitor_create_params.rbs +30 -0
  119. data/sig/deeprails/models/monitor_retrieve_params.rbs +25 -0
  120. data/sig/deeprails/models/monitor_retrieve_response.rbs +167 -0
  121. data/sig/deeprails/models/monitor_submit_event_params.rbs +107 -0
  122. data/sig/deeprails/models/monitor_submit_event_response.rbs +70 -0
  123. data/sig/deeprails/models/monitor_update_params.rbs +55 -0
  124. data/sig/deeprails/models/workflow_event_response.rbs +46 -0
  125. data/sig/deeprails/models.rbs +31 -0
  126. data/sig/deeprails/request_options.rbs +34 -0
  127. data/sig/deeprails/resources/defend.rbs +47 -0
  128. data/sig/deeprails/resources/evaluate.rbs +22 -0
  129. data/sig/deeprails/resources/monitor.rbs +38 -0
  130. data/sig/deeprails/version.rbs +3 -0
  131. metadata +188 -0
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Deeprails
4
+ module Internal
5
+ extend Deeprails::Internal::Util::SorbetRuntimeSupport
6
+
7
+ OMIT =
8
+ Object.new.tap do
9
+ _1.define_singleton_method(:inspect) { "#<#{Deeprails::Internal}::OMIT>" }
10
+ end
11
+ .freeze
12
+
13
+ define_sorbet_constant!(:AnyHash) do
14
+ T.type_alias { T::Hash[Symbol, T.anything] }
15
+ end
16
+ define_sorbet_constant!(:FileInput) do
17
+ T.type_alias { T.any(Pathname, StringIO, IO, String, Deeprails::FilePart) }
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Deeprails
4
+ module Models
5
+ # @see Deeprails::Resources::Monitor#create
6
+ class APIResponse < Deeprails::Internal::Type::BaseModel
7
+ # @!attribute success
8
+ # Represents whether the request was completed successfully.
9
+ #
10
+ # @return [Boolean]
11
+ required :success, Deeprails::Internal::Type::Boolean
12
+
13
+ # @!attribute data
14
+ # Response payload for creating or updating a monitor.
15
+ #
16
+ # @return [Deeprails::Models::APIResponse::Data, nil]
17
+ optional :data, -> { Deeprails::APIResponse::Data }
18
+
19
+ # @!attribute message
20
+ # The accompanying message for the request. Includes error details when
21
+ # applicable.
22
+ #
23
+ # @return [String, nil]
24
+ optional :message, String
25
+
26
+ # @!method initialize(success:, data: nil, message: nil)
27
+ # Some parameter documentations has been truncated, see
28
+ # {Deeprails::Models::APIResponse} for more details.
29
+ #
30
+ # Response wrapper for operations returning a MonitorResponse.
31
+ #
32
+ # @param success [Boolean] Represents whether the request was completed successfully.
33
+ #
34
+ # @param data [Deeprails::Models::APIResponse::Data] Response payload for creating or updating a monitor.
35
+ #
36
+ # @param message [String] The accompanying message for the request. Includes error details when applicable
37
+
38
+ # @see Deeprails::Models::APIResponse#data
39
+ class Data < Deeprails::Internal::Type::BaseModel
40
+ # @!attribute monitor_id
41
+ # A unique monitor ID.
42
+ #
43
+ # @return [String]
44
+ required :monitor_id, String
45
+
46
+ # @!attribute name
47
+ # Name of the monitor.
48
+ #
49
+ # @return [String]
50
+ required :name, String
51
+
52
+ # @!attribute created_at
53
+ # The time the monitor was created in UTC.
54
+ #
55
+ # @return [Time, nil]
56
+ optional :created_at, Time
57
+
58
+ # @!attribute description
59
+ # Description of the monitor.
60
+ #
61
+ # @return [String, nil]
62
+ optional :description, String
63
+
64
+ # @!attribute monitor_status
65
+ # Status of the monitor. Can be `active` or `inactive`. Inactive monitors no
66
+ # longer record and evaluate events.
67
+ #
68
+ # @return [Symbol, Deeprails::Models::APIResponse::Data::MonitorStatus, nil]
69
+ optional :monitor_status, enum: -> { Deeprails::APIResponse::Data::MonitorStatus }
70
+
71
+ # @!attribute updated_at
72
+ # The most recent time the monitor was modified in UTC.
73
+ #
74
+ # @return [Time, nil]
75
+ optional :updated_at, Time
76
+
77
+ # @!attribute user_id
78
+ # User ID of the user who created the monitor.
79
+ #
80
+ # @return [String, nil]
81
+ optional :user_id, String
82
+
83
+ # @!method initialize(monitor_id:, name:, created_at: nil, description: nil, monitor_status: nil, updated_at: nil, user_id: nil)
84
+ # Some parameter documentations has been truncated, see
85
+ # {Deeprails::Models::APIResponse::Data} for more details.
86
+ #
87
+ # Response payload for creating or updating a monitor.
88
+ #
89
+ # @param monitor_id [String] A unique monitor ID.
90
+ #
91
+ # @param name [String] Name of the monitor.
92
+ #
93
+ # @param created_at [Time] The time the monitor was created in UTC.
94
+ #
95
+ # @param description [String] Description of the monitor.
96
+ #
97
+ # @param monitor_status [Symbol, Deeprails::Models::APIResponse::Data::MonitorStatus] Status of the monitor. Can be `active` or `inactive`. Inactive monitors no lon
98
+ #
99
+ # @param updated_at [Time] The most recent time the monitor was modified in UTC.
100
+ #
101
+ # @param user_id [String] User ID of the user who created the monitor.
102
+
103
+ # Status of the monitor. Can be `active` or `inactive`. Inactive monitors no
104
+ # longer record and evaluate events.
105
+ #
106
+ # @see Deeprails::Models::APIResponse::Data#monitor_status
107
+ module MonitorStatus
108
+ extend Deeprails::Internal::Type::Enum
109
+
110
+ ACTIVE = :active
111
+ INACTIVE = :inactive
112
+
113
+ # @!method self.values
114
+ # @return [Array<Symbol>]
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Deeprails
4
+ module Models
5
+ # @see Deeprails::Resources::Defend#create_workflow
6
+ class DefendCreateWorkflowParams < Deeprails::Internal::Type::BaseModel
7
+ extend Deeprails::Internal::Type::RequestParameters::Converter
8
+ include Deeprails::Internal::Type::RequestParameters
9
+
10
+ # @!attribute improvement_action
11
+ # The action used to improve outputs that fail one or guardrail metrics for the
12
+ # workflow events. May be `regenerate`, `fixit`, or null which represents “do
13
+ # nothing”. ReGen runs the user's exact input prompt with minor induced variance.
14
+ # Fixit attempts to directly address the shortcomings of the output using the
15
+ # guardrail failure rationale. Do nothing does not attempt any improvement.
16
+ #
17
+ # @return [Symbol, Deeprails::Models::DefendCreateWorkflowParams::ImprovementAction, nil]
18
+ required :improvement_action,
19
+ enum: -> { Deeprails::DefendCreateWorkflowParams::ImprovementAction },
20
+ nil?: true
21
+
22
+ # @!attribute metrics
23
+ # Mapping of guardrail metrics to floating point threshold values. If the workflow
24
+ # type is automatic, only the metric names are used (`automatic_tolerance`
25
+ # determines thresholds). Possible metrics are `correctness`, `completeness`,
26
+ # `instruction_adherence`, `context_adherence`, `ground_truth_adherence`, or
27
+ # `comprehensive_safety`.
28
+ #
29
+ # @return [Hash{Symbol=>Float}]
30
+ required :metrics, Deeprails::Internal::Type::HashOf[Float]
31
+
32
+ # @!attribute name
33
+ # Name of the workflow.
34
+ #
35
+ # @return [String]
36
+ required :name, String
37
+
38
+ # @!attribute type
39
+ # Type of thresholds to use for the workflow, either `automatic` or `custom`.
40
+ # Automatic thresholds are assigned internally after the user specifies a
41
+ # qualitative tolerance for the metrics, whereas custom metrics allow the user to
42
+ # set the threshold for each metric as a floating point number between 0.0 and
43
+ # 1.0.
44
+ #
45
+ # @return [Symbol, Deeprails::Models::DefendCreateWorkflowParams::Type]
46
+ required :type, enum: -> { Deeprails::DefendCreateWorkflowParams::Type }
47
+
48
+ # @!attribute automatic_tolerance
49
+ # Hallucination tolerance for automatic workflows; may be `low`, `medium`, or
50
+ # `high`. Ignored if `type` is `custom`.
51
+ #
52
+ # @return [Symbol, Deeprails::Models::DefendCreateWorkflowParams::AutomaticTolerance, nil]
53
+ optional :automatic_tolerance, enum: -> { Deeprails::DefendCreateWorkflowParams::AutomaticTolerance }
54
+
55
+ # @!attribute description
56
+ # Description for the workflow.
57
+ #
58
+ # @return [String, nil]
59
+ optional :description, String
60
+
61
+ # @!attribute max_retries
62
+ # Max. number of improvement action retries until a given event passes the
63
+ # guardrails. Defaults to 10.
64
+ #
65
+ # @return [Integer, nil]
66
+ optional :max_retries, Integer
67
+
68
+ # @!method initialize(improvement_action:, metrics:, name:, type:, automatic_tolerance: nil, description: nil, max_retries: nil, request_options: {})
69
+ # Some parameter documentations has been truncated, see
70
+ # {Deeprails::Models::DefendCreateWorkflowParams} for more details.
71
+ #
72
+ # @param improvement_action [Symbol, Deeprails::Models::DefendCreateWorkflowParams::ImprovementAction, nil] The action used to improve outputs that fail one or guardrail metrics for the wo
73
+ #
74
+ # @param metrics [Hash{Symbol=>Float}] Mapping of guardrail metrics to floating point threshold values. If the workflo
75
+ #
76
+ # @param name [String] Name of the workflow.
77
+ #
78
+ # @param type [Symbol, Deeprails::Models::DefendCreateWorkflowParams::Type] Type of thresholds to use for the workflow, either `automatic` or `custom`. Aut
79
+ #
80
+ # @param automatic_tolerance [Symbol, Deeprails::Models::DefendCreateWorkflowParams::AutomaticTolerance] Hallucination tolerance for automatic workflows; may be `low`, `medium`, or `hig
81
+ #
82
+ # @param description [String] Description for the workflow.
83
+ #
84
+ # @param max_retries [Integer] Max. number of improvement action retries until a given event passes the guardra
85
+ #
86
+ # @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}]
87
+
88
+ # The action used to improve outputs that fail one or guardrail metrics for the
89
+ # workflow events. May be `regenerate`, `fixit`, or null which represents “do
90
+ # nothing”. ReGen runs the user's exact input prompt with minor induced variance.
91
+ # Fixit attempts to directly address the shortcomings of the output using the
92
+ # guardrail failure rationale. Do nothing does not attempt any improvement.
93
+ module ImprovementAction
94
+ extend Deeprails::Internal::Type::Enum
95
+
96
+ REGENERATE = :regenerate
97
+ FIXIT = :fixit
98
+
99
+ # @!method self.values
100
+ # @return [Array<Symbol>]
101
+ end
102
+
103
+ # Type of thresholds to use for the workflow, either `automatic` or `custom`.
104
+ # Automatic thresholds are assigned internally after the user specifies a
105
+ # qualitative tolerance for the metrics, whereas custom metrics allow the user to
106
+ # set the threshold for each metric as a floating point number between 0.0 and
107
+ # 1.0.
108
+ module Type
109
+ extend Deeprails::Internal::Type::Enum
110
+
111
+ AUTOMATIC = :automatic
112
+ CUSTOM = :custom
113
+
114
+ # @!method self.values
115
+ # @return [Array<Symbol>]
116
+ end
117
+
118
+ # Hallucination tolerance for automatic workflows; may be `low`, `medium`, or
119
+ # `high`. Ignored if `type` is `custom`.
120
+ module AutomaticTolerance
121
+ extend Deeprails::Internal::Type::Enum
122
+
123
+ LOW = :low
124
+ MEDIUM = :medium
125
+ HIGH = :high
126
+
127
+ # @!method self.values
128
+ # @return [Array<Symbol>]
129
+ end
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,123 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Deeprails
4
+ module Models
5
+ # @see Deeprails::Resources::Defend#create_workflow
6
+ class DefendResponse < Deeprails::Internal::Type::BaseModel
7
+ # @!attribute name
8
+ # Name of the workflow.
9
+ #
10
+ # @return [String]
11
+ required :name, String
12
+
13
+ # @!attribute workflow_id
14
+ # A unique workflow ID.
15
+ #
16
+ # @return [String]
17
+ required :workflow_id, String
18
+
19
+ # @!attribute created_at
20
+ # The time the workflow was created in UTC.
21
+ #
22
+ # @return [Time, nil]
23
+ optional :created_at, Time
24
+
25
+ # @!attribute description
26
+ # Description for the workflow.
27
+ #
28
+ # @return [String, nil]
29
+ optional :description, String
30
+
31
+ # @!attribute improvement_action
32
+ # The action used to improve outputs that fail one or more guardrail metrics for
33
+ # the workflow events. May be `regenerate`, `fixit`, or null which represents “do
34
+ # nothing”. ReGen runs the user's exact input prompt with minor induced variance.
35
+ # Fixit attempts to directly address the shortcomings of the output using the
36
+ # guardrail failure rationale. Do nothing does not attempt any improvement.
37
+ #
38
+ # @return [Symbol, Deeprails::Models::DefendResponse::ImprovementAction, nil]
39
+ optional :improvement_action, enum: -> { Deeprails::DefendResponse::ImprovementAction }, nil?: true
40
+
41
+ # @!attribute max_retries
42
+ # Max. number of improvement action retries until a given event passes the
43
+ # guardrails.
44
+ #
45
+ # @return [Integer, nil]
46
+ optional :max_retries, Integer
47
+
48
+ # @!attribute modified_at
49
+ # The most recent time the workflow was modified in UTC.
50
+ #
51
+ # @return [Time, nil]
52
+ optional :modified_at, Time
53
+
54
+ # @!attribute status
55
+ # Status of the selected workflow. May be `archived` or `active`. Archived
56
+ # workflows will not accept events.
57
+ #
58
+ # @return [Symbol, Deeprails::Models::DefendResponse::Status, nil]
59
+ optional :status, enum: -> { Deeprails::DefendResponse::Status }
60
+
61
+ # @!attribute success_rate
62
+ # Rate of events associated with this workflow that passed evaluation.
63
+ #
64
+ # @return [Float, nil]
65
+ optional :success_rate, Float
66
+
67
+ # @!method initialize(name:, workflow_id:, created_at: nil, description: nil, improvement_action: nil, max_retries: nil, modified_at: nil, status: nil, success_rate: nil)
68
+ # Some parameter documentations has been truncated, see
69
+ # {Deeprails::Models::DefendResponse} for more details.
70
+ #
71
+ # Response payload for guardrail workflow operations.
72
+ #
73
+ # @param name [String] Name of the workflow.
74
+ #
75
+ # @param workflow_id [String] A unique workflow ID.
76
+ #
77
+ # @param created_at [Time] The time the workflow was created in UTC.
78
+ #
79
+ # @param description [String] Description for the workflow.
80
+ #
81
+ # @param improvement_action [Symbol, Deeprails::Models::DefendResponse::ImprovementAction, nil] The action used to improve outputs that fail one or more guardrail metrics for t
82
+ #
83
+ # @param max_retries [Integer] Max. number of improvement action retries until a given event passes the guardra
84
+ #
85
+ # @param modified_at [Time] The most recent time the workflow was modified in UTC.
86
+ #
87
+ # @param status [Symbol, Deeprails::Models::DefendResponse::Status] Status of the selected workflow. May be `archived` or `active`. Archived workf
88
+ #
89
+ # @param success_rate [Float] Rate of events associated with this workflow that passed evaluation.
90
+
91
+ # The action used to improve outputs that fail one or more guardrail metrics for
92
+ # the workflow events. May be `regenerate`, `fixit`, or null which represents “do
93
+ # nothing”. ReGen runs the user's exact input prompt with minor induced variance.
94
+ # Fixit attempts to directly address the shortcomings of the output using the
95
+ # guardrail failure rationale. Do nothing does not attempt any improvement.
96
+ #
97
+ # @see Deeprails::Models::DefendResponse#improvement_action
98
+ module ImprovementAction
99
+ extend Deeprails::Internal::Type::Enum
100
+
101
+ REGENERATE = :regenerate
102
+ FIXIT = :fixit
103
+
104
+ # @!method self.values
105
+ # @return [Array<Symbol>]
106
+ end
107
+
108
+ # Status of the selected workflow. May be `archived` or `active`. Archived
109
+ # workflows will not accept events.
110
+ #
111
+ # @see Deeprails::Models::DefendResponse#status
112
+ module Status
113
+ extend Deeprails::Internal::Type::Enum
114
+
115
+ ARCHIVED = :archived
116
+ ACTIVE = :active
117
+
118
+ # @!method self.values
119
+ # @return [Array<Symbol>]
120
+ end
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Deeprails
4
+ module Models
5
+ # @see Deeprails::Resources::Defend#retrieve_event
6
+ class DefendRetrieveEventParams < Deeprails::Internal::Type::BaseModel
7
+ extend Deeprails::Internal::Type::RequestParameters::Converter
8
+ include Deeprails::Internal::Type::RequestParameters
9
+
10
+ # @!attribute workflow_id
11
+ #
12
+ # @return [String]
13
+ required :workflow_id, String
14
+
15
+ # @!method initialize(workflow_id:, request_options: {})
16
+ # @param workflow_id [String]
17
+ # @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}]
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Deeprails
4
+ module Models
5
+ # @see Deeprails::Resources::Defend#retrieve_workflow
6
+ class DefendRetrieveWorkflowParams < Deeprails::Internal::Type::BaseModel
7
+ extend Deeprails::Internal::Type::RequestParameters::Converter
8
+ include Deeprails::Internal::Type::RequestParameters
9
+
10
+ # @!method initialize(request_options: {})
11
+ # @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}]
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Deeprails
4
+ module Models
5
+ # @see Deeprails::Resources::Defend#submit_event
6
+ class DefendSubmitEventParams < Deeprails::Internal::Type::BaseModel
7
+ extend Deeprails::Internal::Type::RequestParameters::Converter
8
+ include Deeprails::Internal::Type::RequestParameters
9
+
10
+ # @!attribute model_input
11
+ # A dictionary of inputs sent to the LLM to generate output. This must contain a
12
+ # `user_prompt` field and an optional `context` field. Additional properties are
13
+ # allowed.
14
+ #
15
+ # @return [Deeprails::Models::DefendSubmitEventParams::ModelInput]
16
+ required :model_input, -> { Deeprails::DefendSubmitEventParams::ModelInput }
17
+
18
+ # @!attribute model_output
19
+ # Output generated by the LLM to be evaluated.
20
+ #
21
+ # @return [String]
22
+ required :model_output, String
23
+
24
+ # @!attribute model_used
25
+ # Model ID used to generate the output, like `gpt-4o` or `o3`.
26
+ #
27
+ # @return [String]
28
+ required :model_used, String
29
+
30
+ # @!attribute nametag
31
+ # An optional, user-defined tag for the event.
32
+ #
33
+ # @return [String]
34
+ required :nametag, String
35
+
36
+ # @!attribute run_mode
37
+ # Run mode for the workflow event. The run mode allows the user to optimize for
38
+ # speed, accuracy, and cost by determining which models are used to evaluate the
39
+ # event. Available run modes include `precision_plus`, `precision`, `smart`, and
40
+ # `economy`. Defaults to `smart`.
41
+ #
42
+ # @return [Symbol, Deeprails::Models::DefendSubmitEventParams::RunMode]
43
+ required :run_mode, enum: -> { Deeprails::DefendSubmitEventParams::RunMode }
44
+
45
+ # @!method initialize(model_input:, model_output:, model_used:, nametag:, run_mode:, request_options: {})
46
+ # Some parameter documentations has been truncated, see
47
+ # {Deeprails::Models::DefendSubmitEventParams} for more details.
48
+ #
49
+ # @param model_input [Deeprails::Models::DefendSubmitEventParams::ModelInput] A dictionary of inputs sent to the LLM to generate output. This must contain a
50
+ #
51
+ # @param model_output [String] Output generated by the LLM to be evaluated.
52
+ #
53
+ # @param model_used [String] Model ID used to generate the output, like `gpt-4o` or `o3`.
54
+ #
55
+ # @param nametag [String] An optional, user-defined tag for the event.
56
+ #
57
+ # @param run_mode [Symbol, Deeprails::Models::DefendSubmitEventParams::RunMode] Run mode for the workflow event. The run mode allows the user to optimize for s
58
+ #
59
+ # @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}]
60
+
61
+ class ModelInput < Deeprails::Internal::Type::BaseModel
62
+ # @!attribute user_prompt
63
+ #
64
+ # @return [String]
65
+ required :user_prompt, String
66
+
67
+ # @!attribute context
68
+ #
69
+ # @return [String, nil]
70
+ optional :context, String
71
+
72
+ # @!method initialize(user_prompt:, context: nil)
73
+ # A dictionary of inputs sent to the LLM to generate output. This must contain a
74
+ # `user_prompt` field and an optional `context` field. Additional properties are
75
+ # allowed.
76
+ #
77
+ # @param user_prompt [String]
78
+ # @param context [String]
79
+ end
80
+
81
+ # Run mode for the workflow event. The run mode allows the user to optimize for
82
+ # speed, accuracy, and cost by determining which models are used to evaluate the
83
+ # event. Available run modes include `precision_plus`, `precision`, `smart`, and
84
+ # `economy`. Defaults to `smart`.
85
+ module RunMode
86
+ extend Deeprails::Internal::Type::Enum
87
+
88
+ PRECISION_PLUS = :precision_plus
89
+ PRECISION = :precision
90
+ SMART = :smart
91
+ ECONOMY = :economy
92
+
93
+ # @!method self.values
94
+ # @return [Array<Symbol>]
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Deeprails
4
+ module Models
5
+ # @see Deeprails::Resources::Defend#update_workflow
6
+ class DefendUpdateWorkflowParams < Deeprails::Internal::Type::BaseModel
7
+ extend Deeprails::Internal::Type::RequestParameters::Converter
8
+ include Deeprails::Internal::Type::RequestParameters
9
+
10
+ # @!attribute description
11
+ # Description for the workflow.
12
+ #
13
+ # @return [String, nil]
14
+ optional :description, String
15
+
16
+ # @!attribute name
17
+ # Name of the workflow.
18
+ #
19
+ # @return [String, nil]
20
+ optional :name, String
21
+
22
+ # @!attribute type
23
+ # Type of thresholds to use for the workflow, either `automatic` or `custom`.
24
+ #
25
+ # @return [Symbol, Deeprails::Models::DefendUpdateWorkflowParams::Type, nil]
26
+ optional :type, enum: -> { Deeprails::DefendUpdateWorkflowParams::Type }
27
+
28
+ # @!method initialize(description: nil, name: nil, type: nil, request_options: {})
29
+ # @param description [String] Description for the workflow.
30
+ #
31
+ # @param name [String] Name of the workflow.
32
+ #
33
+ # @param type [Symbol, Deeprails::Models::DefendUpdateWorkflowParams::Type] Type of thresholds to use for the workflow, either `automatic` or `custom`.
34
+ #
35
+ # @param request_options [Deeprails::RequestOptions, Hash{Symbol=>Object}]
36
+
37
+ # Type of thresholds to use for the workflow, either `automatic` or `custom`.
38
+ module Type
39
+ extend Deeprails::Internal::Type::Enum
40
+
41
+ AUTOMATIC = :automatic
42
+ CUSTOM = :custom
43
+
44
+ # @!method self.values
45
+ # @return [Array<Symbol>]
46
+ end
47
+ end
48
+ end
49
+ end