Class: Deeprails::Resources::Defend
- Inherits:
-
Object
- Object
- Deeprails::Resources::Defend
- Defined in:
- lib/deeprails/resources/defend.rb
Instance Method Summary collapse
-
#create_workflow(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: {}) ⇒ Deeprails::Models::DefendCreateResponse
Some parameter documentations has been truncated, see Models::DefendCreateWorkflowParams for more details.
-
#initialize(client:) ⇒ Defend
constructor
private
A new instance of Defend.
-
#retrieve_event(event_id, workflow_id:, request_options: {}) ⇒ Deeprails::Models::WorkflowEventDetailResponse
Use this endpoint to retrieve a specific event of a guardrail workflow.
-
#retrieve_workflow(workflow_id, limit: nil, request_options: {}) ⇒ Deeprails::Models::DefendResponse
Some parameter documentations has been truncated, see Models::DefendRetrieveWorkflowParams for more details.
-
#submit_and_stream_event_streaming(workflow_id, model_input:, model_output:, model_used:, run_mode:, stream: nil, nametag: nil, request_options: {}) ⇒ Deeprails::Internal::Stream<String>
Some parameter documentations has been truncated, see Models::DefendSubmitAndStreamEventParams for more details.
-
#submit_event(workflow_id, model_input:, model_output:, model_used:, run_mode:, nametag: nil, request_options: {}) ⇒ Deeprails::Models::WorkflowEventResponse
Some parameter documentations has been truncated, see Models::DefendSubmitEventParams for more details.
-
#update_workflow(workflow_id, automatic_hallucination_tolerance_levels: nil, context_awareness: nil, custom_hallucination_threshold_values: nil, description: nil, file_search: nil, improvement_action: nil, max_improvement_attempts: nil, name: nil, threshold_type: nil, web_search: nil, request_options: {}) ⇒ Deeprails::Models::DefendUpdateResponse
Some parameter documentations has been truncated, see Models::DefendUpdateWorkflowParams for more details.
Constructor Details
#initialize(client:) ⇒ Defend
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Defend.
232 233 234 |
# File 'lib/deeprails/resources/defend.rb', line 232 def initialize(client:) @client = client end |
Instance Method Details
#create_workflow(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: {}) ⇒ Deeprails::Models::DefendCreateResponse
Some parameter documentations has been truncated, see Models::DefendCreateWorkflowParams for more details.
Use this endpoint to create a new guardrail workflow by specifying guardrail thresholds, an improvement action, and optional extended capabilities.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/deeprails/resources/defend.rb', line 39 def create_workflow(params) parsed, = Deeprails::DefendCreateWorkflowParams.dump_request(params) @client.request( method: :post, path: "defend", body: parsed, model: Deeprails::DefendCreateResponse, options: ) end |
#retrieve_event(event_id, workflow_id:, request_options: {}) ⇒ Deeprails::Models::WorkflowEventDetailResponse
Use this endpoint to retrieve a specific event of a guardrail workflow
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/deeprails/resources/defend.rb', line 63 def retrieve_event(event_id, params) parsed, = Deeprails::DefendRetrieveEventParams.dump_request(params) workflow_id = parsed.delete(:workflow_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["defend/%1$s/events/%2$s", workflow_id, event_id], model: Deeprails::WorkflowEventDetailResponse, options: ) end |
#retrieve_workflow(workflow_id, limit: nil, request_options: {}) ⇒ Deeprails::Models::DefendResponse
Some parameter documentations has been truncated, see Models::DefendRetrieveWorkflowParams for more details.
Use this endpoint to retrieve the details for a specific defend workflow
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/deeprails/resources/defend.rb', line 93 def retrieve_workflow(workflow_id, params = {}) parsed, = Deeprails::DefendRetrieveWorkflowParams.dump_request(params) query = Deeprails::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["defend/%1$s", workflow_id], query: query, model: Deeprails::DefendResponse, options: ) end |
#submit_and_stream_event_streaming(workflow_id, model_input:, model_output:, model_used:, run_mode:, stream: nil, nametag: nil, request_options: {}) ⇒ Deeprails::Internal::Stream<String>
Some parameter documentations has been truncated, see Models::DefendSubmitAndStreamEventParams for more details.
Use this endpoint to submit a model input and output pair to a workflow for evaluation with streaming responses.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/deeprails/resources/defend.rb', line 132 def submit_and_stream_event_streaming(workflow_id, params) query_params = [:stream] parsed, = Deeprails::DefendSubmitAndStreamEventParams.dump_request(params) query = Deeprails::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :post, path: ["defend/%1$s/events?stream=true", workflow_id], query: query, headers: {"accept" => "text/event-stream"}, body: parsed.except(*query_params), stream: Deeprails::Internal::Stream, model: String, options: ) end |
#submit_event(workflow_id, model_input:, model_output:, model_used:, run_mode:, nametag: nil, request_options: {}) ⇒ Deeprails::Models::WorkflowEventResponse
Some parameter documentations has been truncated, see Models::DefendSubmitEventParams for more details.
Use this endpoint to submit a model input and output pair to a workflow for evaluation
173 174 175 176 177 178 179 180 181 182 |
# File 'lib/deeprails/resources/defend.rb', line 173 def submit_event(workflow_id, params) parsed, = Deeprails::DefendSubmitEventParams.dump_request(params) @client.request( method: :post, path: ["defend/%1$s/events", workflow_id], body: parsed, model: Deeprails::WorkflowEventResponse, options: ) end |
#update_workflow(workflow_id, automatic_hallucination_tolerance_levels: nil, context_awareness: nil, custom_hallucination_threshold_values: nil, description: nil, file_search: nil, improvement_action: nil, max_improvement_attempts: nil, name: nil, threshold_type: nil, web_search: nil, request_options: {}) ⇒ Deeprails::Models::DefendUpdateResponse
Some parameter documentations has been truncated, see Models::DefendUpdateWorkflowParams for more details.
Use this endpoint to update an existing defend workflow if its details change.
218 219 220 221 222 223 224 225 226 227 |
# File 'lib/deeprails/resources/defend.rb', line 218 def update_workflow(workflow_id, params = {}) parsed, = Deeprails::DefendUpdateWorkflowParams.dump_request(params) @client.request( method: :put, path: ["defend/%1$s", workflow_id], body: parsed, model: Deeprails::DefendUpdateResponse, options: ) end |