Align Ollama system prompts with OpenAI

This commit is contained in:
Adolfo Reyna
2026-03-17 01:19:28 -04:00
parent 53060918e9
commit 96fe560f6f
+10 -2
View File
@@ -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"