Class: Smith::Workflow::AgentResult

Inherits:
Struct
  • Object
show all
Defined in:
lib/smith/workflow/agent_result.rb

Overview

rubocop:disable Style/RedundantStructKeywordInit

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



6
7
8
# File 'lib/smith/workflow/agent_result.rb', line 6

def content
  @content
end

#costObject

Returns the value of attribute cost

Returns:

  • (Object)

    the current value of cost



6
7
8
# File 'lib/smith/workflow/agent_result.rb', line 6

def cost
  @cost
end

#input_tokensObject

Returns the value of attribute input_tokens

Returns:

  • (Object)

    the current value of input_tokens



6
7
8
# File 'lib/smith/workflow/agent_result.rb', line 6

def input_tokens
  @input_tokens
end

#model_usedObject

Returns the value of attribute model_used

Returns:

  • (Object)

    the current value of model_used



6
7
8
# File 'lib/smith/workflow/agent_result.rb', line 6

def model_used
  @model_used
end

#output_tokensObject

Returns the value of attribute output_tokens

Returns:

  • (Object)

    the current value of output_tokens



6
7
8
# File 'lib/smith/workflow/agent_result.rb', line 6

def output_tokens
  @output_tokens
end

Class Method Details

.from_response(response, content, model_used: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/smith/workflow/agent_result.rb', line 10

def self.from_response(response, content, model_used: nil)
  new(
    content: content,
    input_tokens: response.respond_to?(:input_tokens) ? response.input_tokens : nil,
    output_tokens: response.respond_to?(:output_tokens) ? response.output_tokens : nil,
    cost: nil,
    model_used: model_used
  )
end

Instance Method Details

#usage_known?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/smith/workflow/agent_result.rb', line 20

def usage_known?
  !input_tokens.nil? && !output_tokens.nil?
end