Candil.RequestBuilder (Candil v1.0.0)

Copy Markdown View Source

Shared request body builders for LLM providers.

These functions normalise messages and build the JSON-compatible request body maps for OpenAI-compatible, Anthropic, and Ollama APIs. Both the Candil.Inference (non-streaming) and Candil.Stream (SSE streaming) modules delegate here to avoid code duplication.

Options

  • :temperature — sampling temperature (default: 0.7)
  • :max_tokens — maximum tokens to generate (default: 512)
  • :stop — list of stop sequences (OpenAI only, default: [])
  • :system — system prompt string (prepended to messages)
  • :stream — enable SSE streaming (default: false)

All functions return a plain map ready for Jason.encode!/1.