Class: Rubyagents::ActionStep

Inherits:
Data
  • Object
show all
Defined in:
lib/rubyagents/memory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step_number:, thought:, code: nil, tool_calls: nil, observation: nil, error: nil, duration: 0.0, token_usage: nil) ⇒ ActionStep

Returns a new instance of ActionStep.



5
6
7
8
# File 'lib/rubyagents/memory.rb', line 5

def initialize(step_number:, thought:, code: nil, tool_calls: nil, observation: nil, error: nil,
               duration: 0.0, token_usage: nil)
  super
end

Instance Attribute Details

#code ⇒ Object (readonly)

Returns the value of attribute code

Returns:

  • (Object) —

    the current value of code



4
5
6
# File 'lib/rubyagents/memory.rb', line 4

def code
  @code
end

#duration ⇒ Object (readonly)

Returns the value of attribute duration

Returns:

  • (Object) —

    the current value of duration



4
5
6
# File 'lib/rubyagents/memory.rb', line 4

def duration
  @duration
end

#error ⇒ Object (readonly)

Returns the value of attribute error

Returns:

  • (Object) —

    the current value of error



4
5
6
# File 'lib/rubyagents/memory.rb', line 4

def error
  @error
end

#observation ⇒ Object (readonly)

Returns the value of attribute observation

Returns:

  • (Object) —

    the current value of observation



4
5
6
# File 'lib/rubyagents/memory.rb', line 4

def observation
  @observation
end

#step_number ⇒ Object (readonly)

Returns the value of attribute step_number

Returns:

  • (Object) —

    the current value of step_number



4
5
6
# File 'lib/rubyagents/memory.rb', line 4

def step_number
  @step_number
end

#thought ⇒ Object (readonly)

Returns the value of attribute thought

Returns:

  • (Object) —

    the current value of thought



4
5
6
# File 'lib/rubyagents/memory.rb', line 4

def thought
  @thought
end

#token_usage ⇒ Object (readonly)

Returns the value of attribute token_usage

Returns:

  • (Object) —

    the current value of token_usage



4
5
6
# File 'lib/rubyagents/memory.rb', line 4

def token_usage
  @token_usage
end

#tool_calls ⇒ Object (readonly)

Returns the value of attribute tool_calls

Returns:

  • (Object) —

    the current value of tool_calls



4
5
6
# File 'lib/rubyagents/memory.rb', line 4

def tool_calls
  @tool_calls
end

Instance Method Details

#to_h ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/rubyagents/memory.rb', line 10

def to_h
  h = { type: "action", step_number: step_number, thought: thought, duration: duration }
  h[:code] = code if code
  h[:tool_calls] = tool_calls.map(&:to_h) if tool_calls
  h[:observation] = observation if observation
  h[:error] = error if error
  h[:token_usage] = token_usage.to_h if token_usage
  h
end