View Source AI.Completion (fnord v0.5.8)

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

Summary

Types

error()

@type error() :: {:error, String.t()}

response()

@type response() :: success() | error()

success()

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

t()

@type t() :: %AI.Completion{
  ai: AI.t(),
  log_msgs: boolean(),
  log_tool_call_results: boolean(),
  log_tool_calls: boolean(),
  max_tokens: non_neg_integer(),
  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

context_window_usage(map)

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)