Class: Vellum::AsyncDeploymentsClient

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:) ⇒ AsyncDeploymentsClient

Parameters:



90
91
92
93
# File 'lib/vellum_ai/deployments/client.rb', line 90

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

Instance Attribute Details

#request_clientObject (readonly)

Returns the value of attribute request_client.



86
87
88
# File 'lib/vellum_ai/deployments/client.rb', line 86

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:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/vellum_ai/deployments/client.rb', line 101

def list(limit: nil, offset: nil, ordering: nil, status: nil, request_options: nil)
  Async do
    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
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:



125
126
127
128
129
130
131
132
133
134
135
# File 'lib/vellum_ai/deployments/client.rb', line 125

def retrieve(id:, request_options: nil)
  Async do
    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
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:



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/vellum_ai/deployments/client.rb', line 143

def retrieve_provider_payload(inputs:, deployment_id: nil, deployment_name: nil, release_tag: nil,
                              request_options: nil)
  Async do
    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
end