Class: OllamaAgent::ToolRuntime::OllamaJsonPlanner

Inherits:
Object
  • Object
show all
Includes:
PlanExtractor
Defined in:
lib/ollama_agent/tool_runtime/ollama_json_planner.rb

Overview

Asks an Ollama chat model for the next tool call as a single JSON object.

Instance Method Summary collapse

Constructor Details

#initialize(client:, model: nil, chat_options: nil) ⇒ OllamaJsonPlanner

Returns a new instance of OllamaJsonPlanner.

Parameters:



15
16
17
18
19
# File 'lib/ollama_agent/tool_runtime/ollama_json_planner.rb', line 15

def initialize(client:, model: nil, chat_options: nil)
  @client = client
  @model = resolve_model(model)
  @chat_options = chat_options || { temperature: 0.2 }
end

Instance Method Details

#next_step(context:, memory:, registry:) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/ollama_agent/tool_runtime/ollama_json_planner.rb', line 21

def next_step(context:, memory:, registry:)
  prompt = build_prompt(context: context, memory: memory, registry: registry)
  response = @client.chat(
    model: @model,
    messages: [{ role: "user", content: prompt }],
    options: @chat_options
  )
  content = assistant_content(response)
  JsonExtractor.extract_object(content)
end