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:
@@ -57,7 +57,8 @@ After transcription, text passes through these stages in order:
|
||||
1. **Custom dictionary** — case-insensitive whole-word regex replacements
|
||||
from `dictation_custom_dictionary`. Each entry is `"wrong -> right"`.
|
||||
2. **LLM filler removal** (optional) — when `dictation_filler_removal` is
|
||||
enabled, sends the text to the local Ollama instance (same model as the
|
||||
enabled, sends the text to the local LLM server (Ollama, or the
|
||||
OpenAI-compatible `/chat/completions` when the URL ends in `/v1`; same model as the
|
||||
assistant) with a prompt to remove filler words (um, uh, like, you know,
|
||||
etc.) while preserving meaning. Uses a 5-second timeout; falls back to the
|
||||
unprocessed text on failure.
|
||||
|
||||
@@ -450,6 +450,15 @@ def _llm_clean_dictation(text: str, ollama_base_url: str, model: str = "gemma4:e
|
||||
f"{text}"
|
||||
)
|
||||
|
||||
from ..llm import call_llm_direct, is_openai_compatible
|
||||
|
||||
if is_openai_compatible(ollama_base_url):
|
||||
cleaned = (call_llm_direct(ollama_base_url, model, "", prompt, timeout_sec=5, thinking=thinking) or "").strip()
|
||||
if cleaned:
|
||||
debug_log(f"LLM filler removal: {text!r} → {cleaned!r}", "dictation")
|
||||
return cleaned
|
||||
return text
|
||||
|
||||
try:
|
||||
resp = requests.post(
|
||||
f"{ollama_base_url}/api/generate",
|
||||
|
||||
Reference in New Issue
Block a user