Class: Vellum::SandboxesClient
- Inherits:
-
Object
- Object
- Vellum::SandboxesClient
- 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:) ⇒ SandboxesClient 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:) ⇒ SandboxesClient
14 15 16 17 |
# File 'lib/vellum_ai/sandboxes/client.rb', line 14 def initialize(request_client:) # @type [RequestClient] @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Object (readonly)
Returns the value of attribute request_client.
10 11 12 |
# File 'lib/vellum_ai/sandboxes/client.rb', line 10 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.
59 60 61 62 63 64 65 66 |
# File 'lib/vellum_ai/sandboxes/client.rb', line 59 def delete_sandbox_scenario(id:, scenario_id:, request_options: nil) @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 |
#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.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vellum_ai/sandboxes/client.rb', line 37 def upsert_sandbox_scenario(id:, inputs:, label: nil, scenario_id: nil, request_options: nil) 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 |