From 96fe560f6f452ab58f3c2a6faf0260c3f363259a Mon Sep 17 00:00:00 2001 From: Adolfo Reyna Date: Tue, 17 Mar 2026 01:19:28 -0400 Subject: [PATCH] Align Ollama system prompts with OpenAI --- engine_llm.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/engine_llm.py b/engine_llm.py index ecf47fd..6ed296c 100644 --- a/engine_llm.py +++ b/engine_llm.py @@ -51,6 +51,7 @@ def run_llm_processor(in_queue, out_queue, args): json={ "model": args.post_correct_model, "prompt": "Return exactly: ok", + "system": "You are a concise assistant.", "stream": False, "options": {"temperature": 0.0}, "keep_alive": getattr(args, "post_correct_keep_alive", "30m"), @@ -112,12 +113,13 @@ def run_llm_processor(in_queue, out_queue, args): raise RuntimeError(f"OpenAI API error {response.status_code}: {detail}") return response.json()["choices"][0]["message"]["content"].strip() - def call_ollama(prompt, temperature): + def call_ollama(prompt, temperature, system=None): response = requests.post( getattr(args, "post_correct_ollama_url", "http://127.0.0.1:11434/api/generate"), json={ "model": args.post_correct_model, "prompt": prompt, + "system": system or "", "stream": False, "options": {"temperature": temperature}, "keep_alive": getattr(args, "post_correct_keep_alive", "30m"), @@ -133,7 +135,13 @@ def run_llm_processor(in_queue, out_queue, args): if not api_key: raise RuntimeError("OPENAI_API_KEY is not set") return call_openai(messages) - return call_ollama(prompt, temperature) + system = "" + if messages: + for message in messages: + if message.get("role") == "system": + system = message.get("content", "") + break + return call_ollama(prompt, temperature, system=system) except Exception as exc: if not llm_state[warn_key]: label = "Paragraph LLM" if warn_key == "paragraph_warned" else "Line LLM"