Class: RubyLLM::Team::Run

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/team/run.rb

Overview

Imperative convenience wrapper around one Team::Session.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ Run

Returns a new instance of Run.



12
13
14
# File 'lib/ruby_llm/team/run.rb', line 12

def initialize(session)
  @session = session
end

Instance Attribute Details

#sessionObject (readonly)

Returns the value of attribute session.



10
11
12
# File 'lib/ruby_llm/team/run.rb', line 10

def session
  @session
end

Instance Method Details

#artifact(name) ⇒ Object



33
# File 'lib/ruby_llm/team/run.rb', line 33

def artifact(name) = session.artifact(name)

#artifacts(name) ⇒ Object



34
# File 'lib/ruby_llm/team/run.rb', line 34

def artifacts(name) = session.artifacts(name)

#callsObject



35
# File 'lib/ruby_llm/team/run.rb', line 35

def calls = session.calls

#calls_remainingObject



36
# File 'lib/ruby_llm/team/run.rb', line 36

def calls_remaining = session.calls_remaining

#output(name = OUTPUT_UNSET) ⇒ Object

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
29
30
# File 'lib/ruby_llm/team/run.rb', line 22

def output(name = OUTPUT_UNSET)
  return selected_output if name.equal?(OUTPUT_UNSET)

  name = name.to_s
  raise ArgumentError, "No completed artifact named '#{name}'" unless artifact(name)

  @output_name = name
  self
end

#step(name, with:, prompt: nil, from: nil) ⇒ Object

Omitting from: hands over the latest version of every completed artifact, matching Session#ask; pass from: [] to start clean.



18
19
20
# File 'lib/ruby_llm/team/run.rb', line 18

def step(name, with:, prompt: nil, from: nil)
  session.ask(with, prompt || "Complete '#{name}'.", as: name, from: from)
end

#to_h(include_content: false) ⇒ Object



38
# File 'lib/ruby_llm/team/run.rb', line 38

def to_h(include_content: false) = session.to_h(include_content: include_content)

#to_json(*args, include_content: false) ⇒ Object

Mirrors Session#to_json, positional generator state included, so JSON.generate(run) works the same way.



42
# File 'lib/ruby_llm/team/run.rb', line 42

def to_json(*args, include_content: false) = session.to_json(*args, include_content: include_content)

#to_markdownObject



37
# File 'lib/ruby_llm/team/run.rb', line 37

def to_markdown = session.to_markdown

#value(name) ⇒ Object



32
# File 'lib/ruby_llm/team/run.rb', line 32

def value(name) = session.value(name)