Class: Legion::LLM::NativeResponseAdapter

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_tokensObject (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_tokensObject (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

#contentObject (readonly)

Returns the value of attribute content.



11
12
13
# File 'lib/legion/llm/native_dispatch.rb', line 11

def content
  @content
end

#input_tokensObject (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_tokensObject (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

#usageObject (readonly)

Returns the value of attribute usage.



11
12
13
# File 'lib/legion/llm/native_dispatch.rb', line 11

def usage
  @usage
end