Class: Ollama::Agent::Planner
- Inherits:
-
Object
- Object
- Ollama::Agent::Planner
- Defined in:
- lib/ollama/agent/planner.rb
Overview
Stateless planner-style agent using /api/generate.
Intended for planning, classification, routing, and deterministic structured outputs.
Constant Summary collapse
- ANY_JSON_SCHEMA =
{ "anyOf" => [ { "type" => "object", "additionalProperties" => true }, { "type" => "array" }, { "type" => "string" }, { "type" => "number" }, { "type" => "integer" }, { "type" => "boolean" }, { "type" => "null" } ] }.freeze
Instance Method Summary collapse
-
#initialize(client) ⇒ Planner
constructor
A new instance of Planner.
-
#run(prompt:, context: nil, schema: nil) ⇒ Object
Parsed JSON (Hash/Array/String/Number/Boolean/Nil).
Constructor Details
#initialize(client) ⇒ Planner
Returns a new instance of Planner.
24 25 26 |
# File 'lib/ollama/agent/planner.rb', line 24 def initialize(client) @client = client end |
Instance Method Details
#run(prompt:, context: nil, schema: nil) ⇒ Object
Returns Parsed JSON (Hash/Array/String/Number/Boolean/Nil).
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ollama/agent/planner.rb', line 32 def run(prompt:, context: nil, schema: nil) full_prompt = prompt.to_s full_prompt = "#{full_prompt}\n\nContext (JSON):\n#{JSON.pretty_generate(context)}" if context && !context.empty? @client.generate( prompt: full_prompt, schema: schema || ANY_JSON_SCHEMA, strict: true ) end |