feat(llm): talk to OpenAI-compatible servers such as Strata
A base URL that ends in /v1 now selects the OpenAI-compatible API: chat goes to /chat/completions and embeddings to /embeddings. The conversion lives in src/jarvis/llm.py only, so the reply engine and every other caller keep their Ollama-shaped messages and responses. - Requests drop private engine keys, send tool-call arguments as JSON strings, map num_predict to max_tokens and the thinking switch to chat_template_kwargs.enable_thinking, and leave out num_ctx and keep_alive. - Responses come back with message.content, tool calls with dict arguments and an id, and message.thinking from reasoning_content. - Streaming, the warm-up (one-token chat completion), the intent judge and the dictation clean-up use the same path. A server without an embedding model fails open to the text paths. - Specs and docs/llm_contexts.md describe the transport; roadmap records M3 step 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -77,7 +77,7 @@ Design principles enforced by the engine:
|
||||
6. Agentic Messages Loop with Dynamic Context
|
||||
- For each turn of the loop (max `agentic_max_turns` turns, default 8):
|
||||
- Update first system message with fresh time/location context
|
||||
- Send messages to LLM — try native tool calling first (Ollama `tools` API parameter)
|
||||
- Send messages to LLM — try native tool calling first (`tools` API parameter; Ollama `/api/chat`, or `/chat/completions` when `ollama_base_url` ends in `/v1`, see the transport note in `docs/llm_contexts.md`)
|
||||
- If the model returns HTTP 400 (native tools API not supported), automatically fall back
|
||||
to text-based tool calling for the rest of the session:
|
||||
- Rebuild system message to inject tool descriptions and markdown fence instructions
|
||||
@@ -140,7 +140,7 @@ Design principles enforced by the engine:
|
||||
- LLM returns empty response with no tool calls for multiple turns
|
||||
|
||||
Tool protocol details:
|
||||
- Native tool calling (default): Tools are passed to Ollama via the `tools` API parameter in OpenAI-compatible JSON schema format; the LLM requests tools via the standard `tool_calls` field
|
||||
- Native tool calling (default): Tools are passed to the LLM server (Ollama, or an OpenAI-compatible server such as Strata) via the `tools` API parameter in OpenAI-compatible JSON schema format; the LLM requests tools via the standard `tool_calls` field
|
||||
- Text-based fallback (automatic): If the model returns HTTP 400, the engine switches to injecting tool descriptions as plain text in the system message and parsing `` ```tool_call ``` `` markdown fences from the model's content field
|
||||
- Fallback is detected once per session (first HTTP 400 response) and persists for the rest of the conversation
|
||||
- Internal reasoning uses the `thinking` field (not shown to user)
|
||||
|
||||
Reference in New Issue
Block a user