Eai. LLM. Direct
(eai v0.1.15)
Copy Markdown
Direct LLM API orchestration using Converse-based internal message IR.
All internal history is [Eai.Message.t()]. Before sending to an LLM provider,
the appropriate adapter converts messages to provider-specific wire format.
Responses are parsed back into Eai.Message.t(). LLM requests
flow through Pipeline.llm_pre_hooks/4 and llm_post_hooks/5
for pre/post request interception.
Summary
Functions
Run LLM tool-calling loop with messages.
Functions
Run LLM tool-calling loop with messages.
Internal API called by Chat.talk/1. Handles model selection, adapter routing,
tool execution, and result polling.
Options (map)
:model(atom) — Model name::deepseek,:claude_opus, etc.Default: from config `:default_model`:prompt(atom) — System prompt::momoka,:coder,:analyst, etc.Default: `:momoka`:chat_session_id(string) — Session for multi-session isolation.Default: `"default"`:card_system_prompt(string) — Extra system prompt (role layer, appended).Default: nil:card_tools(list) — Allowlist of tool names. Default: all tools:card_pre_context(list) — Pre-loaded messages (for prefix caching).Default: nil
Internal fields (filled automatically by Chat.talk, do NOT set externally):
:provider— Adapter provider (:anthropic,:openai_compat, etc.):api_key— LLM API key (from env):url— LLM endpoint URL:receive_timeout— HTTP timeout in ms:reasoning_effort— Model-specific (e.g., "high" for DeepSeek):model_str— Actual model string for API
Returns
`{:ok, final_reply}` or `{:error, reason}`Example (internal, called by Chat.talk)
iex> Eai.LLM.Direct.run(
messages,
"default",
%{model: :deepseek, prompt: :coder, chat_session_id: "work"}
)
{:ok, "Here's the refactored code..."}