Class: Vellum::Client
- Inherits:
-
Object
- Object
- Vellum::Client
- Defined in:
- lib/vellum_ai.rb
Instance Attribute Summary collapse
-
#deployments ⇒ Object
readonly
Returns the value of attribute deployments.
-
#document_indexes ⇒ Object
readonly
Returns the value of attribute document_indexes.
-
#documents ⇒ Object
readonly
Returns the value of attribute documents.
-
#folder_entities ⇒ Object
readonly
Returns the value of attribute folder_entities.
-
#model_versions ⇒ Object
readonly
Returns the value of attribute model_versions.
-
#registered_prompts ⇒ Object
readonly
Returns the value of attribute registered_prompts.
-
#sandboxes ⇒ Object
readonly
Returns the value of attribute sandboxes.
-
#test_suite_runs ⇒ Object
readonly
Returns the value of attribute test_suite_runs.
-
#test_suites ⇒ Object
readonly
Returns the value of attribute test_suites.
-
#workflow_deployments ⇒ Object
readonly
Returns the value of attribute workflow_deployments.
Instance Method Summary collapse
-
#execute_prompt(inputs:, prompt_deployment_id: nil, prompt_deployment_name: nil, release_tag: nil, external_id: nil, expand_meta: nil, raw_overrides: nil, expand_raw: nil, metadata: nil, request_options: nil) ⇒ ExecutePromptResponse
Executes a deployed Prompt and returns the result.
-
#execute_workflow(inputs:, workflow_deployment_id: nil, workflow_deployment_name: nil, release_tag: nil, external_id: nil, request_options: nil) ⇒ ExecuteWorkflowResponse
Executes a deployed Workflow and returns its outputs.
-
#generate(requests:, deployment_id: nil, deployment_name: nil, options: nil, request_options: nil) ⇒ GenerateResponse
Generate a completion using a previously defined deployment.
- #initialize(api_key:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil) ⇒ Client constructor
-
#search(query:, index_id: nil, index_name: nil, options: nil, request_options: nil) ⇒ SearchResponse
Perform a search against a document index.
-
#submit_completion_actuals(actuals:, deployment_id: nil, deployment_name: nil, request_options: nil) ⇒ Void
Used to submit feedback regarding the quality of previously generated completions.
-
#submit_workflow_execution_actuals(actuals:, execution_id: nil, external_id: nil, request_options: nil) ⇒ Void
Used to submit feedback regarding the quality of previous workflow execution and its outputs.
Constructor Details
#initialize(api_key:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil) ⇒ Client
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/vellum_ai.rb', line 40 def initialize(api_key:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil) @request_client = RequestClient.new(environment: environment, max_retries: max_retries, timeout_in_seconds: timeout_in_seconds, api_key: api_key) @deployments = DeploymentsClient.new(request_client: @request_client) @document_indexes = DocumentIndexesClient.new(request_client: @request_client) @documents = DocumentsClient.new(request_client: @request_client) @folder_entities = FolderEntitiesClient.new(request_client: @request_client) @model_versions = ModelVersionsClient.new(request_client: @request_client) @registered_prompts = RegisteredPromptsClient.new(request_client: @request_client) @sandboxes = SandboxesClient.new(request_client: @request_client) @test_suite_runs = TestSuiteRunsClient.new(request_client: @request_client) @test_suites = TestSuitesClient.new(request_client: @request_client) @workflow_deployments = WorkflowDeploymentsClient.new(request_client: @request_client) end |
Instance Attribute Details
#deployments ⇒ Object (readonly)
Returns the value of attribute deployments.
32 33 34 |
# File 'lib/vellum_ai.rb', line 32 def deployments @deployments end |
#document_indexes ⇒ Object (readonly)
Returns the value of attribute document_indexes.
32 33 34 |
# File 'lib/vellum_ai.rb', line 32 def document_indexes @document_indexes end |
#documents ⇒ Object (readonly)
Returns the value of attribute documents.
32 33 34 |
# File 'lib/vellum_ai.rb', line 32 def documents @documents end |
#folder_entities ⇒ Object (readonly)
Returns the value of attribute folder_entities.
32 33 34 |
# File 'lib/vellum_ai.rb', line 32 def folder_entities @folder_entities end |
#model_versions ⇒ Object (readonly)
Returns the value of attribute model_versions.
32 33 34 |
# File 'lib/vellum_ai.rb', line 32 def model_versions @model_versions end |
#registered_prompts ⇒ Object (readonly)
Returns the value of attribute registered_prompts.
32 33 34 |
# File 'lib/vellum_ai.rb', line 32 def registered_prompts @registered_prompts end |
#sandboxes ⇒ Object (readonly)
Returns the value of attribute sandboxes.
32 33 34 |
# File 'lib/vellum_ai.rb', line 32 def sandboxes @sandboxes end |
#test_suite_runs ⇒ Object (readonly)
Returns the value of attribute test_suite_runs.
32 33 34 |
# File 'lib/vellum_ai.rb', line 32 def test_suite_runs @test_suite_runs end |
#test_suites ⇒ Object (readonly)
Returns the value of attribute test_suites.
32 33 34 |
# File 'lib/vellum_ai.rb', line 32 def test_suites @test_suites end |
#workflow_deployments ⇒ Object (readonly)
Returns the value of attribute workflow_deployments.
32 33 34 |
# File 'lib/vellum_ai.rb', line 32 def workflow_deployments @workflow_deployments end |
Instance Method Details
#execute_prompt(inputs:, prompt_deployment_id: nil, prompt_deployment_name: nil, release_tag: nil, external_id: nil, expand_meta: nil, raw_overrides: nil, expand_raw: nil, metadata: nil, request_options: nil) ⇒ ExecutePromptResponse
Executes a deployed Prompt and returns the result.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/vellum_ai.rb', line 76 def execute_prompt(inputs:, prompt_deployment_id: nil, prompt_deployment_name: nil, release_tag: nil, external_id: nil, expand_meta: nil, raw_overrides: nil, expand_raw: nil, metadata: 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 || {}), inputs: inputs, prompt_deployment_id: prompt_deployment_id, prompt_deployment_name: prompt_deployment_name, release_tag: release_tag, external_id: external_id, expand_meta: , raw_overrides: raw_overrides, expand_raw: , metadata: }.compact req.url "#{@request_client.default_environment[:Predict]}/v1/execute-prompt" end ExecutePromptResponse.from_json(json_object: response.body) end |
#execute_workflow(inputs:, workflow_deployment_id: nil, workflow_deployment_name: nil, release_tag: nil, external_id: nil, request_options: nil) ⇒ ExecuteWorkflowResponse
Executes a deployed Workflow and returns its outputs.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/vellum_ai.rb', line 108 def execute_workflow(inputs:, workflow_deployment_id: nil, workflow_deployment_name: nil, release_tag: nil, external_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 || {}), inputs: inputs, workflow_deployment_id: workflow_deployment_id, workflow_deployment_name: workflow_deployment_name, release_tag: release_tag, external_id: external_id }.compact req.url "#{@request_client.default_environment[:Predict]}/v1/execute-workflow" end ExecuteWorkflowResponse.from_json(json_object: response.body) end |
#generate(requests:, deployment_id: nil, deployment_name: nil, options: nil, request_options: nil) ⇒ GenerateResponse
Generate a completion using a previously defined deployment.
Note: Uses a base url of ‘predict.vellum.ai`.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/vellum_ai.rb', line 141 def generate(requests:, deployment_id: nil, deployment_name: nil, options: 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 || {}), deployment_id: deployment_id, deployment_name: deployment_name, requests: requests, options: }.compact req.url "#{@request_client.default_environment[:Predict]}/v1/generate" end GenerateResponse.from_json(json_object: response.body) end |
#search(query:, index_id: nil, index_name: nil, options: nil, request_options: nil) ⇒ SearchResponse
Perform a search against a document index.
Note: Uses a base url of ‘predict.vellum.ai`.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/vellum_ai.rb', line 183 def search(query:, index_id: nil, index_name: nil, options: 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 || {}), index_id: index_id, index_name: index_name, query: query, options: }.compact req.url "#{@request_client.default_environment[:Predict]}/v1/search" end SearchResponse.from_json(json_object: response.body) end |
#submit_completion_actuals(actuals:, deployment_id: nil, deployment_name: nil, request_options: nil) ⇒ Void
Used to submit feedback regarding the quality of previously generated completions.
Note: Uses a base url of ‘predict.vellum.ai`.
214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/vellum_ai.rb', line 214 def submit_completion_actuals(actuals:, deployment_id: nil, deployment_name: nil, request_options: nil) @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 || {}), deployment_id: deployment_id, deployment_name: deployment_name, actuals: actuals }.compact req.url "#{@request_client.default_environment[:Predict]}/v1/submit-completion-actuals" end end |
#submit_workflow_execution_actuals(actuals:, execution_id: nil, external_id: nil, request_options: nil) ⇒ Void
Used to submit feedback regarding the quality of previous workflow execution and its outputs.
**Note:** Uses a base url of `https://predict.vellum.ai`.
238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/vellum_ai.rb', line 238 def submit_workflow_execution_actuals(actuals:, execution_id: nil, external_id: nil, request_options: nil) @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 || {}), actuals: actuals, execution_id: execution_id, external_id: external_id }.compact req.url "#{@request_client.default_environment[:Predict]}/v1/submit-workflow-execution-actuals" end end |