Class: OllamaAgent::Skills::LlmClient
- Inherits:
-
Object
- Object
- OllamaAgent::Skills::LlmClient
- Defined in:
- lib/ollama_agent/skills/llm_client.rb
Overview
Thin facade over Providers::Registry tuned for deterministic, single-shot JSON generation. Defaults to the local Ollama provider so skills stay local-first and auditable. Inject any object responding to #generate in tests.
Constant Summary collapse
- DEFAULT_TEMPERATURE =
0.0- DEFAULT_PROVIDER =
"ollama"
Instance Method Summary collapse
-
#generate(prompt) ⇒ String
Raw assistant content.
-
#initialize(provider: nil, model: nil, temperature: DEFAULT_TEMPERATURE) ⇒ LlmClient
constructor
A new instance of LlmClient.
Constructor Details
#initialize(provider: nil, model: nil, temperature: DEFAULT_TEMPERATURE) ⇒ LlmClient
Returns a new instance of LlmClient.
15 16 17 18 19 |
# File 'lib/ollama_agent/skills/llm_client.rb', line 15 def initialize(provider: nil, model: nil, temperature: DEFAULT_TEMPERATURE) @provider = provider || Providers::Registry.resolve(DEFAULT_PROVIDER) @model = model || ENV.fetch("OLLAMA_AGENT_SKILL_MODEL", default_model) @temperature = temperature end |
Instance Method Details
#generate(prompt) ⇒ String
Returns raw assistant content.
23 24 25 26 27 28 29 |
# File 'lib/ollama_agent/skills/llm_client.rb', line 23 def generate(prompt) response = @provider.chat(messages: [(prompt)], model: @model, temperature: @temperature) content = response.content raise OllamaAgent::Error, "empty response from provider" if content.to_s.strip.empty? content end |