Class: Legion::LLM::NativeResponseAdapter
- Inherits:
-
Object
- Object
- Legion::LLM::NativeResponseAdapter
- Defined in:
- lib/legion/llm/native_dispatch.rb
Overview
Wraps a native dispatch result hash so it exposes the same interface that RubyLLM response objects expose (used by Pipeline::Executor and ConversationStore after a provider call).
Instance Attribute Summary collapse
-
#cache_read_tokens ⇒ Object
readonly
Returns the value of attribute cache_read_tokens.
-
#cache_write_tokens ⇒ Object
readonly
Returns the value of attribute cache_write_tokens.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#input_tokens ⇒ Object
readonly
Returns the value of attribute input_tokens.
-
#output_tokens ⇒ Object
readonly
Returns the value of attribute output_tokens.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
-
#initialize(result_hash) ⇒ NativeResponseAdapter
constructor
A new instance of NativeResponseAdapter.
Constructor Details
#initialize(result_hash) ⇒ NativeResponseAdapter
Returns a new instance of NativeResponseAdapter.
14 15 16 17 18 19 20 21 22 |
# File 'lib/legion/llm/native_dispatch.rb', line 14 def initialize(result_hash) @content = result_hash[:result].to_s usage = result_hash[:usage] || Usage.new @usage = usage @input_tokens = usage.input_tokens @output_tokens = usage.output_tokens @cache_read_tokens = usage.cache_read_tokens @cache_write_tokens = usage.cache_write_tokens end |
Instance Attribute Details
#cache_read_tokens ⇒ Object (readonly)
Returns the value of attribute cache_read_tokens.
11 12 13 |
# File 'lib/legion/llm/native_dispatch.rb', line 11 def cache_read_tokens @cache_read_tokens end |
#cache_write_tokens ⇒ Object (readonly)
Returns the value of attribute cache_write_tokens.
11 12 13 |
# File 'lib/legion/llm/native_dispatch.rb', line 11 def cache_write_tokens @cache_write_tokens end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
11 12 13 |
# File 'lib/legion/llm/native_dispatch.rb', line 11 def content @content end |
#input_tokens ⇒ Object (readonly)
Returns the value of attribute input_tokens.
11 12 13 |
# File 'lib/legion/llm/native_dispatch.rb', line 11 def input_tokens @input_tokens end |
#output_tokens ⇒ Object (readonly)
Returns the value of attribute output_tokens.
11 12 13 |
# File 'lib/legion/llm/native_dispatch.rb', line 11 def output_tokens @output_tokens end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
11 12 13 |
# File 'lib/legion/llm/native_dispatch.rb', line 11 def usage @usage end |