Class: Vellum::AsyncSandboxesClient
- Inherits:
-
Object
- Object
- Vellum::AsyncSandboxesClient
- Defined in:
- lib/vellum_ai/sandboxes/client.rb
Instance Attribute Summary collapse
-
#request_client ⇒ Object
readonly
Returns the value of attribute request_client.
Instance Method Summary collapse
-
#delete_sandbox_scenario(id:, scenario_id:, request_options: nil) ⇒ Void
Deletes an existing scenario from a sandbox, keying off of the provided scenario id.
- #initialize(request_client:) ⇒ AsyncSandboxesClient constructor
-
#upsert_sandbox_scenario(id:, inputs:, label: nil, scenario_id: nil, request_options: nil) ⇒ SandboxScenario
Upserts a new scenario for a sandbox, keying off of the optionally provided scenario id.
Constructor Details
#initialize(request_client:) ⇒ AsyncSandboxesClient
74 75 76 77 |
# File 'lib/vellum_ai/sandboxes/client.rb', line 74 def initialize(request_client:) # @type [AsyncRequestClient] @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Object (readonly)
Returns the value of attribute request_client.
70 71 72 |
# File 'lib/vellum_ai/sandboxes/client.rb', line 70 def request_client @request_client end |
Instance Method Details
#delete_sandbox_scenario(id:, scenario_id:, request_options: nil) ⇒ Void
Deletes an existing scenario from a sandbox, keying off of the provided scenario id.
121 122 123 124 125 126 127 128 129 130 |
# File 'lib/vellum_ai/sandboxes/client.rb', line 121 def delete_sandbox_scenario(id:, scenario_id:, request_options: nil) Async do @request_client.conn.delete do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X_API_KEY"] = .api_key unless &.api_key.nil? req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.url "#{@request_client.default_environment[:Default]}/v1/sandboxes/#{id}/scenarios/#{scenario_id}" end end end |
#upsert_sandbox_scenario(id:, inputs:, label: nil, scenario_id: nil, request_options: nil) ⇒ SandboxScenario
Upserts a new scenario for a sandbox, keying off of the optionally provided scenario id.
If an id is provided and has a match, the scenario will be updated. If no id is provided or no match is found, a new scenario will be appended to the end.
Note that a full replacement of the scenario is performed, so any fields not provided will be removed or overwritten with default values.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/vellum_ai/sandboxes/client.rb', line 97 def upsert_sandbox_scenario(id:, inputs:, label: nil, scenario_id: nil, request_options: nil) Async do response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X_API_KEY"] = .api_key unless &.api_key.nil? req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(&.additional_body_parameters || {}), label: label, inputs: inputs, scenario_id: scenario_id }.compact req.url "#{@request_client.default_environment[:Default]}/v1/sandboxes/#{id}/scenarios" end SandboxScenario.from_json(json_object: response.body) end end |