Class: Handinger::Resources::Tasks

Inherits:
Object
  • Object
show all
Defined in:
lib/handinger/resources/tasks.rb

Overview

Run and inspect tasks against a worker.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Tasks

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Tasks.

Parameters:



71
72
73
# File 'lib/handinger/resources/tasks.rb', line 71

def initialize(client:)
  @client = client
end

Instance Method Details

#create(worker_id:, instructions: nil, output_schema: nil, prompt: nil, summary: nil, task_id: nil, title: nil, visibility: nil, request_options: {}) ⇒ Handinger::Models::Worker

Some parameter documentations has been truncated, see Models::TaskCreateParams for more details.

Run a new task against an existing worker. Send ‘multipart/form-data` to attach files; the bytes are bootstrapped into the worker’s workspace before the task starts.

Parameters:

  • worker_id (String)

    Worker id the task belongs to.

  • instructions (String)

    Persistent system prompt the worker uses for every task it runs.

  • output_schema (Hash{Symbol=>Object})

    Optional JSON Schema (Draft-07) describing the structured object the worker must

  • prompt (String)

    Natural-language description of the worker to use for AI-generated instructions

  • summary (String)

    Short one-line description of the worker’s purpose. Auto-generated when omitted

  • task_id (String)

    Optional client-provided task id. Reuse this id to add turns to an existing task

  • title (String)

    Optional display name. When omitted, Handinger assigns a random dog-themed name.

  • visibility (Symbol, Handinger::Models::CreateTask::Visibility)

    ‘public` (default) is visible to all org members. `private` is only visible to i

  • request_options (Handinger::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



37
38
39
40
41
42
43
44
45
46
# File 'lib/handinger/resources/tasks.rb', line 37

def create(params)
  parsed, options = Handinger::TaskCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/tasks",
    body: parsed,
    model: Handinger::Worker,
    options: options
  )
end

#retrieve(task_id, request_options: {}) ⇒ Handinger::Models::TaskWithTurns

Retrieve a single task and its individual turns.

Parameters:

  • task_id (String)

    Task id returned by the create task endpoint.

  • request_options (Handinger::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



59
60
61
62
63
64
65
66
# File 'lib/handinger/resources/tasks.rb', line 59

def retrieve(task_id, params = {})
  @client.request(
    method: :get,
    path: ["api/tasks/%1$s", task_id],
    model: Handinger::TaskWithTurns,
    options: params[:request_options]
  )
end