Module: Ollama::Prompts

Defined in:
lib/ollama/prompts/tool_planner.rb

Overview

Prompt templates for agent behavior.

Class Method Summary collapse

Class Method Details

.tool_planner(tools:, rules: []) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ollama/prompts/tool_planner.rb', line 6

def self.tool_planner(tools:, rules: [])
  tool_lines = tools.map do |t|
    name = t[:name] || t["name"]
    description = t[:description] || t["description"]
    "- #{name}: #{description}"
  end.join("\n")

  rules_text = rules.map { |r| "- #{r}" }.join("\n")

  <<~PROMPT
    You are a planner.

    Available tools:
    #{tool_lines}

    Rules:
    #{rules_text}
    - Call ONLY one tool at a time
    - If no more actions are needed, return action = "finish"
    - Respond ONLY in JSON

    JSON format:
    {
      "action": "tool_name | finish",
      "input": { }
    }
  PROMPT
end