Class: Smith::Workflow::AgentResult
- Inherits:
-
Struct
- Object
- Struct
- Smith::Workflow::AgentResult
- Defined in:
- lib/smith/workflow.rb
Overview
keyword_init: true so adding new fields in future schema versions remains backward-compatible: ‘from_response` and `from_h` can fill extra fields without breaking existing call sites that pass the historical positional args. Reading old persisted records into a newer Struct shape: from_h slices to current members (unknown keys silently dropped; missing keys default to nil).
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#cost ⇒ Object
Returns the value of attribute cost.
-
#input_tokens ⇒ Object
Returns the value of attribute input_tokens.
-
#model_used ⇒ Object
Returns the value of attribute model_used.
-
#output_tokens ⇒ Object
Returns the value of attribute output_tokens.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content
79 80 81 |
# File 'lib/smith/workflow.rb', line 79 def content @content end |
#cost ⇒ Object
Returns the value of attribute cost
79 80 81 |
# File 'lib/smith/workflow.rb', line 79 def cost @cost end |
#input_tokens ⇒ Object
Returns the value of attribute input_tokens
79 80 81 |
# File 'lib/smith/workflow.rb', line 79 def input_tokens @input_tokens end |
#model_used ⇒ Object
Returns the value of attribute model_used
79 80 81 |
# File 'lib/smith/workflow.rb', line 79 def model_used @model_used end |
#output_tokens ⇒ Object
Returns the value of attribute output_tokens
79 80 81 |
# File 'lib/smith/workflow.rb', line 79 def output_tokens @output_tokens end |
Class Method Details
.from_response(response, content, model_used: nil) ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/smith/workflow.rb', line 83 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
93 94 95 |
# File 'lib/smith/workflow.rb', line 93 def usage_known? !input_tokens.nil? && !output_tokens.nil? end |