Class: Vellum::AsyncWorkflowsClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ Vellum::AsyncWorkflowsClient

Parameters:



184
185
186
# File 'lib/vellum_ai/workflows/client.rb', line 184

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientVellum::AsyncRequestClient (readonly)



179
180
181
# File 'lib/vellum_ai/workflows/client.rb', line 179

def request_client
  @request_client
end

Instance Method Details

#pull(id:, exclude_code: nil, exclude_display: nil, include_json: nil, include_sandbox: nil, release_tag: nil, strict: nil, version: nil, request_options: nil, &on_data) ⇒ Void

Returns:

  • (Void)


202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/vellum_ai/workflows/client.rb', line 202

def pull(id:, exclude_code: nil, exclude_display: nil, include_json: nil, include_sandbox: nil, release_tag: nil, strict: nil, version: nil, request_options: nil, &on_data)
  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 || {}) }.compact
  req.options.on_data = on_data
  req.params = { **(request_options&.additional_query_parameters || {}), "exclude_code": exclude_code, "exclude_display": exclude_display, "include_json": include_json, "include_sandbox": include_sandbox, "release_tag": release_tag, "strict": strict, "version": version }.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: Predict, request_options: request_options)}/v1/workflows/#{id}/pull"
end
  end
end

#push(exec_config:, workflow_sandbox_id: nil, deployment_config: nil, artifact: nil, dataset: nil, dry_run: nil, strict: nil, request_options: nil) ⇒ Vellum::WorkflowPushResponse

Parameters:

  • exec_config (String)

    The execution configuration of the workflow.

  • workflow_sandbox_id (String) (defaults to: nil)
  • deployment_config (Hash) (defaults to: nil)

    Request of type Vellum::WorkflowPushDeploymentConfigRequest, as a Hash

    • :label (String)

    • :name (String)

    • :description (String)

    • :release_tags (Array<String>)

    • :release_description (String)

  • artifact (String, IO) (defaults to: nil)
  • dataset (Array<Hash>) (defaults to: nil)

    List of dataset rows with inputs for scenarios.Request of type Array<Vellum::DatasetRowPushRequest>, as a Hash

    • :label (String)

    • :inputs (Hash=> Object)

  • dry_run (Boolean) (defaults to: nil)
  • strict (Boolean) (defaults to: nil)
  • request_options (Vellum::RequestOptions) (defaults to: nil)

Returns:



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/vellum_ai/workflows/client.rb', line 281

def push(exec_config:, workflow_sandbox_id: nil, deployment_config: nil, artifact: nil, dataset: nil, dry_run: nil, strict: nil, 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 || {}), exec_config: exec_config, workflow_sandbox_id: workflow_sandbox_id, deployment_config: deployment_config, artifact: unless artifact.nil?
  Vellum::FileUtilities.as_faraday_multipart(file_like: artifact)
end, dataset: dataset, dry_run: dry_run, strict: strict }.compact
  req.url "#{@request_client.get_url(environment: Default, request_options: request_options)}/v1/workflows/push"
end
    Vellum::WorkflowPushResponse.from_json(json_object: response.body)
  end
end

#retrieve_state(span_id:, request_options: nil) ⇒ Object

api.workflows.retrieve_state(span_id: “span_id”)



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/vellum_ai/workflows/client.rb', line 239

def retrieve_state(span_id:, 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 || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  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: Predict, request_options: request_options)}/v1/workflows/#{span_id}/state"
end
    Vellum::WorkflowResolvedState.from_json(json_object: response.body)
  end
end

#serialize_workflow_files(files:, module_: nil, request_options: nil) ⇒ Object

api.workflows.serialize_workflow_files(files: { “files”: “key”:“value” })



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/vellum_ai/workflows/client.rb', line 320

def serialize_workflow_files(files:, module_: nil, 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 || {}), files: files, module: module_ }.compact
  req.url "#{@request_client.get_url(environment: Default, request_options: request_options)}/v1/workflows/serialize"
end
    parsed_json = JSON.parse(response.body)
    parsed_json
  end
end