Class: Vellum::AsyncPromptsClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ Vellum::AsyncPromptsClient

Parameters:



119
120
121
# File 'lib/vellum_ai/prompts/client.rb', line 119

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientVellum::AsyncRequestClient (readonly)



114
115
116
# File 'lib/vellum_ai/prompts/client.rb', line 114

def request_client
  @request_client
end

Instance Method Details

#pull(id:, prompt_variant_id: nil, request_options: nil) ⇒ Object

api.prompts.pull(id: “id”)



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/vellum_ai/prompts/client.rb', line 136

def pull(id:, prompt_variant_id: nil, request_options: nil)
  Async do
    response = @request_client.conn.get do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.api_key.nil?
req.headers["X-API-KEY"] = request_options.api_key
  end
  unless request_options&.api_version.nil?
req.headers["X-API-Version"] = request_options.api_version
  else
req.headers["X-API-Version"] = "2025-07-30"
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}), "Accept": "application/json" }.compact
  req.params = { **(request_options&.additional_query_parameters || {}), "prompt_variant_id": prompt_variant_id }.compact
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
  end
  req.url "#{@request_client.get_url(environment: Default, request_options: request_options)}/v1/prompts/#{id}/pull"
end
    Vellum::PromptExecConfig.from_json(json_object: response.body)
  end
end

#push(prompt_variant_id: nil, prompt_variant_label: nil, prompt_sandbox_id: nil, exec_config:, request_options: nil) ⇒ Object

api.prompts.push(exec_config: { ml_model: “ml_model”, input_variables: [{ id: “x”, key: “key”, type: STRING }, { id: “x”, key: “key”, type: STRING }], parameters: { }, blocks: [{ block_type: “JINJA”, template: “template” }, { block_type: “JINJA”, template: “template” }] })



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/vellum_ai/prompts/client.rb', line 193

def push(prompt_variant_id: nil, prompt_variant_label: nil, prompt_sandbox_id: nil, exec_config:, request_options: nil)
  Async do
    response = @request_client.conn.post do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.api_key.nil?
req.headers["X-API-KEY"] = request_options.api_key
  end
  unless request_options&.api_version.nil?
req.headers["X-API-Version"] = request_options.api_version
  else
req.headers["X-API-Version"] = "2025-07-30"
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  req.body = { **(request_options&.additional_body_parameters || {}), prompt_variant_id: prompt_variant_id, prompt_variant_label: prompt_variant_label, prompt_sandbox_id: prompt_sandbox_id, exec_config: exec_config }.compact
  req.url "#{@request_client.get_url(environment: Default, request_options: request_options)}/v1/prompts/push"
end
    Vellum::PromptPushResponse.from_json(json_object: response.body)
  end
end