Class: Vellum::DeploymentsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai/deployments/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ DeploymentsClient

Parameters:



17
18
19
20
# File 'lib/vellum_ai/deployments/client.rb', line 17

def initialize(request_client:)
  # @type [RequestClient]
  @request_client = request_client
end

Instance Attribute Details

#request_clientObject (readonly)

Returns the value of attribute request_client.



13
14
15
# File 'lib/vellum_ai/deployments/client.rb', line 13

def request_client
  @request_client
end

Instance Method Details

#list(limit: nil, offset: nil, ordering: nil, status: nil, request_options: nil) ⇒ PaginatedSlimDeploymentReadList

Parameters:

  • limit (Integer) (defaults to: nil)

    Number of results to return per page.

  • offset (Integer) (defaults to: nil)

    The initial index from which to return the results.

  • ordering (String) (defaults to: nil)

    Which field to use when ordering the results.

  • status (DEPLOYMENTS_LIST_REQUEST_STATUS) (defaults to: nil)

    status

  • request_options (RequestOptions) (defaults to: nil)

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/vellum_ai/deployments/client.rb', line 28

def list(limit: nil, offset: nil, ordering: nil, status: nil, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
    req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
    req.params = {
      **(request_options&.additional_query_parameters || {}),
      "limit": limit,
      "offset": offset,
      "ordering": ordering,
      "status": status
    }.compact
    req.url "#{@request_client.default_environment[:Default]}/v1/deployments"
  end
  PaginatedSlimDeploymentReadList.from_json(json_object: response.body)
end

#retrieve(id:, request_options: nil) ⇒ DeploymentRead

Used to retrieve a deployment given its ID or name.

Parameters:

  • id (String)

    Either the Deployment’s ID or its unique name

  • request_options (RequestOptions) (defaults to: nil)

Returns:



50
51
52
53
54
55
56
57
58
# File 'lib/vellum_ai/deployments/client.rb', line 50

def retrieve(id:, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
    req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
    req.url "#{@request_client.default_environment[:Default]}/v1/deployments/#{id}"
  end
  DeploymentRead.from_json(json_object: response.body)
end

#retrieve_provider_payload(inputs:, deployment_id: nil, deployment_name: nil, release_tag: nil, request_options: nil) ⇒ DeploymentProviderPayloadResponse

Parameters:

  • deployment_id (String) (defaults to: nil)

    The ID of the deployment. Must provide either this or deployment_name.

  • deployment_name (String) (defaults to: nil)

    The name of the deployment. Must provide either this or deployment_id.

  • inputs (Array<Hash>)

    The list of inputs defined in the Prompt’s deployment with their corresponding values.Request of type Array<PromptDeploymentInputRequest>, as a Hash

  • release_tag (String) (defaults to: nil)

    Optionally specify a release tag if you want to pin to a specific release of the Workflow Deployment

  • request_options (RequestOptions) (defaults to: nil)

Returns:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/vellum_ai/deployments/client.rb', line 66

def retrieve_provider_payload(inputs:, deployment_id: nil, deployment_name: nil, release_tag: nil,
                              request_options: nil)
  response = @request_client.conn.post do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["X_API_KEY"] = request_options.api_key unless request_options&.api_key.nil?
    req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
    req.body = {
      **(request_options&.additional_body_parameters || {}),
      deployment_id: deployment_id,
      deployment_name: deployment_name,
      inputs: inputs,
      release_tag: release_tag
    }.compact
    req.url "#{@request_client.default_environment[:Default]}/v1/deployments/provider-payload"
  end
  DeploymentProviderPayloadResponse.from_json(json_object: response.body)
end