View Source AI.Completion (fnord v0.6.1)

This module sends a request to the model and handles the response. It is able to handle tool calls and responses.

Output options

Output is controlled by the following mechanisms.

  1. log_msgs - log messages from the user and assistant as info
  2. log_tool_calls - log tool calls as info and tool call results as debug

LOGGER_LEVEL must be set to debug to see the output of tool call results.

Summary

Types

response()

@type response() :: {:ok, t()}

t()

@type t() :: %AI.Completion{
  ai: AI.t(),
  log_msgs: boolean(),
  log_tool_calls: boolean(),
  messages: list(),
  model: String.t(),
  opts: Keyword.t(),
  replay_conversation: boolean(),
  response: String.t() | nil,
  tool_call_requests: list(),
  tools: list(),
  use_planner: boolean()
}

Functions

get(ai, opts)

@spec get(AI.t(), Keyword.t()) :: response()

get_completion(state)

handle_tool_call(state, map)

new(ai, opts)

new_from_conversation(conversation, ai, opts)

tools_used(map)