Class: OmniAI::OpenAI::Thread::Runs

Inherits:
Object
  • Object
show all
Defined in:
lib/omniai/openai/thread/runs.rb

Overview

An OpenAI scope for establishing messages.

Instance Method Summary collapse

Constructor Details

#initialize(client:, thread:) ⇒ Runs

Returns a new instance of Runs.

Parameters:



10
11
12
13
# File 'lib/omniai/openai/thread/runs.rb', line 10

def initialize(client:, thread:)
  @client = client
  @thread = thread
end

Instance Method Details

#all(limit: nil) ⇒ Array<OmniAI::Thread::Message>

Parameters:

  • limit (Integer) (defaults to: nil)

    optional

Returns:

  • (Array<OmniAI::Thread::Message>)


17
18
19
# File 'lib/omniai/openai/thread/runs.rb', line 17

def all(limit: nil)
  Run.all(thread_id: @thread.id, limit:, client: @client)
end

#build(assistant_id:, model: nil, temperature: nil, instructions: nil, tools: nil, metadata: {}) ⇒ OmniAI::OpenAI::Thread::Message

Parameters:

  • assistant_id (String)

    required

  • model (String, nil) (defaults to: nil)

    optional

  • temperature (Float, nil) (defaults to: nil)

    optional

  • instructions (String, nil) (defaults to: nil)

    optional

  • tools (Array<Hash>, nil) (defaults to: nil)

    optional

  • metadata (Hash, nil) (defaults to: {})

    optional

Returns:



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/omniai/openai/thread/runs.rb', line 40

def build(assistant_id:, model: nil, temperature: nil, instructions: nil, tools: nil, metadata: {})
  Run.new(
    assistant_id:,
    thread_id: @thread.id,
    model:,
    temperature:,
    instructions:,
    tools:,
    metadata:,
    client: @client
  )
end

#cancel!(id:) ⇒ Hash

Parameters:

  • id (String)

    required

Returns:

  • (Hash)


29
30
31
# File 'lib/omniai/openai/thread/runs.rb', line 29

def cancel!(id:)
  Run.cancel!(id:, thread_id: @thread.id, client: @client)
end

#find(id:) ⇒ OmniAI::OpenAI::Thread::Message

Parameters:

  • id (String)

    required

Returns:



23
24
25
# File 'lib/omniai/openai/thread/runs.rb', line 23

def find(id:)
  Run.find(id:, thread_id: @thread.id, client: @client)
end