Packages

fnord

0.4.21

AI code archaeology

Current section

Files

Jump to
fnord lib ai tools planner.ex
Raw

lib/ai/tools/planner.ex

defmodule AI.Tools.Planner do
require Logger
@behaviour AI.Tools
@impl AI.Tools
def spec() do
%{
type: "function",
function: %{
name: "planner_tool",
description: "analyze the conversation and suggest the next steps",
parameters: %{
type: "object",
required: [],
properties: %{}
}
}
}
end
@impl AI.Tools
def call(agent, _args) do
Logger.info("[planner] examining findings and planning the next steps")
agent
|> AI.Agent.Planner.new()
|> AI.Agent.Planner.get_suggestion()
|> then(fn
{:ok, suggestion} ->
Logger.debug("[planner]: #{suggestion}")
{:ok, "[planner_tool]\n#{suggestion}"}
{:error, reason} ->
Logger.error("[planner] error getting suggestion: #{reason}")
{:error, reason}
end)
end
end