LlmCall.Request (llm_call v0.4.0)

Copy Markdown View Source

A provider-neutral completion request.

system stays here rather than becoming a message because providers place it differently (leading message, top-level field, or instruction field). It is text-only: no protocol accepts a non-text system block, so a wider type would promise what validation refuses.

provider_options is keyed by provider namespace and is for features the canonical layer cannot express. params covers the sampling and length controls providers share.

Summary

Types

t()

A tool entry: a canonical spec, a ToolCall module, or {module, opts}.

Types

modalities()

@type modalities() :: [LlmCall.modality()]

output()

@type output() ::
  :text | :json_object | {:json_schema, String.t(), map(), boolean() | nil}

params()

@type params() :: %{
  optional(atom()) => nil | boolean() | number() | String.t() | [String.t()]
}

system()

@type system() :: nil | String.t() | [LlmCall.Content.Text.t()]

t()

@type t() :: %LlmCall.Request{
  messages: [LlmCall.Message.t()],
  modalities: modalities(),
  model: String.t(),
  output: output(),
  params: params(),
  provider_options: map(),
  reasoning: LlmCall.Reasoning.t() | nil,
  stream: boolean(),
  system: system(),
  tool_choice: tool_choice(),
  tools: [tool_entry()]
}

tool_choice()

@type tool_choice() ::
  :auto | :none | :required | {:tool, String.t()} | {:allowed, [String.t()]}

tool_entry()

@type tool_entry() :: LlmCall.ToolSpec.t() | module() | {module(), keyword()}

A tool entry: a canonical spec, a ToolCall module, or {module, opts}.

A module expands to one LlmCall.ToolSpec per declared tool when the request is encoded, with the schema projected for the codec's protocol. Callers that already hold specs pass them unchanged.