Class: Llmemory::LLM::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/llmemory/llm/base.rb

Direct Known Subclasses

Anthropic, OpenAI

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



11
12
13
# File 'lib/llmemory/llm/base.rb', line 11

def initialize(*)
  @last_usage = Usage.zero
end

Instance Attribute Details

#last_usageObject (readonly)

Returns the value of attribute last_usage.



9
10
11
# File 'lib/llmemory/llm/base.rb', line 9

def last_usage
  @last_usage
end

Instance Method Details

#invoke(prompt) ⇒ Object

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/llmemory/llm/base.rb', line 15

def invoke(prompt)
  raise NotImplementedError, "#{self.class}#invoke must be implemented"
end

#invoke_with_json_schema(_prompt, _json_schema) ⇒ Object

Optional: Structured Outputs (JSON schema). Override in providers that support it (e.g. OpenAI). When not overridden, returns nil and callers should fall back to invoke + parse.



21
22
23
# File 'lib/llmemory/llm/base.rb', line 21

def invoke_with_json_schema(_prompt, _json_schema)
  nil
end