Class: Vellum::AsyncPromptsClient
- Inherits:
-
Object
- Object
- Vellum::AsyncPromptsClient
- Defined in:
- lib/vellum_ai/prompts/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #initialize(request_client:) ⇒ Vellum::AsyncPromptsClient constructor
-
#pull(id:, prompt_variant_id: nil, request_options: nil) ⇒ Object
api.prompts.pull(id: “id”).
-
#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” }] }).
Constructor Details
#initialize(request_client:) ⇒ Vellum::AsyncPromptsClient
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_client ⇒ Vellum::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 &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.api_key.nil? req.headers["X-API-KEY"] = .api_key end unless &.api_version.nil? req.headers["X-API-Version"] = .api_version else req.headers["X-API-Version"] = "2025-07-30" end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}), "Accept": "application/json" }.compact req.params = { **(&.additional_query_parameters || {}), "prompt_variant_id": prompt_variant_id }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(environment: Default, 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 &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.api_key.nil? req.headers["X-API-KEY"] = .api_key end unless &.api_version.nil? req.headers["X-API-Version"] = .api_version else req.headers["X-API-Version"] = "2025-07-30" end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.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: )}/v1/prompts/push" end Vellum::PromptPushResponse.from_json(json_object: response.body) end end |