Class: Rubyagents::RunResult

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output:, state:, steps: [], token_usage: nil, timing: nil) ⇒ RunResult

Returns a new instance of RunResult.



42
43
44
# File 'lib/rubyagents/model.rb', line 42

def initialize(output:, state:, steps: [], token_usage: nil, timing: nil)
  super
end

Instance Attribute Details

#output ⇒ Object (readonly)

Returns the value of attribute output

Returns:

  • (Object) —

    the current value of output



41
42
43
# File 'lib/rubyagents/model.rb', line 41

def output
  @output
end

#state ⇒ Object (readonly)

Returns the value of attribute state

Returns:

  • (Object) —

    the current value of state



41
42
43
# File 'lib/rubyagents/model.rb', line 41

def state
  @state
end

#steps ⇒ Object (readonly)

Returns the value of attribute steps

Returns:

  • (Object) —

    the current value of steps



41
42
43
# File 'lib/rubyagents/model.rb', line 41

def steps
  @steps
end

#timing ⇒ Object (readonly)

Returns the value of attribute timing

Returns:

  • (Object) —

    the current value of timing



41
42
43
# File 'lib/rubyagents/model.rb', line 41

def timing
  @timing
end

#token_usage ⇒ Object (readonly)

Returns the value of attribute token_usage

Returns:

  • (Object) —

    the current value of token_usage



41
42
43
# File 'lib/rubyagents/model.rb', line 41

def token_usage
  @token_usage
end

Instance Method Details

#success? ⇒ Boolean

Returns:

  • (Boolean)


46
# File 'lib/rubyagents/model.rb', line 46

def success? = state == "success"

#to_h ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/rubyagents/model.rb', line 48

def to_h
  {
    output: output,
    state: state,
    steps: steps.map(&:to_h),
    token_usage: token_usage&.to_h,
    timing: timing
  }
end

#to_json(*args) ⇒ Object



58
59
60
61
# File 'lib/rubyagents/model.rb', line 58

def to_json(*args)
  require "json"
  to_h.to_json(*args)
end