M6-R1 Hotfix: Pipe-Prompt-KeyError ("queries") + Ollama-API-500 in Modellliste

- Pipe: str.format() durch .replace() ersetzt (JSON-Braces im Prompt), non-stream
  Pfad mit try/except; sha256-Pin aktualisiert (5ddb6191...)
- ENABLE_OLLAMA_API=False in open_webui_env: ohne Ollama auf dem Host lieferte
  GET /ollama/api/version beim Oeffnen der Modellliste HTTP 500
- Verifiziert: function-Content in webui.db = 5ddb6191..., Container-Env korrekt,
  webui.yml ok=37 changed=3 dann idempotent changed=0

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-11-15 14:21:23 +01:00
parent 60474b20d3
commit 09a8ac4948
3 changed files with 35 additions and 14 deletions
@@ -131,6 +131,19 @@ nach OWUI-v0.13.3 Reserved-Args (`user_prompt` lesen, History cappen).
- Rate-Limit-Doku und LLM-Metriken im Monitoring bleiben M6-Restpunkte
(GNAI-001 M6).
## 5a. Befunde aus dem ersten Live-Test (14.11.2026)
- **Fehler `"queries"` in der Pipe:** die Prompts enthielten JSON-Beispiele
(`{"queries": …}`) und wurden per `str.format()` gerendert — die Braces
kollidierten mit Format-Feldern (KeyError). Fix: `.replace("{qpr}", …)`;
neuer sha256-Pin `5ddb6191…`. Non-Streaming-Pfad fängt Exceptions jetzt ab
und meldet sie als Text.
- **HTTP 500 `GET /ollama/api/version` beim Öffnen der Modellliste:** v0.13.3
ruft den Ollama-Endpoint mit `ENABLE_OLLAMA_API=True` (Default) — ohne
Ollama auf dem Host 500. Fix: `ENABLE_OLLAMA_API=False` in `open_webui_env`.
- Verifiziert nach Redeploy: function-Content in DB sha256 `5ddb6191…`,
`ENABLE_OLLAMA_API=False` im Container, Playbook idempotent `changed=0`.
## 6. Sicherheit
- Pipe-Code läuft serverseitig in OpenWebUI (OWUI-Warnung: Functions sind
@@ -39,7 +39,7 @@ open_webui_web_search_tool_id: gnai-web-search
# sha256 (recompute after every edit of files/gnai-deep-research-pipe.py:
# sha256sum files/gnai-deep-research-pipe.py).
open_webui_deep_research_function_id: gnai-deep-research
open_webui_deep_research_pipe_sha256: "1458b6a91b0aa159954e58318e3d263726e743b3c4d6088cadfe26c40a2400d7"
open_webui_deep_research_pipe_sha256: "5ddb6191c7e94789d2e1bf33b775092a38d6fe5c5762653d07084dcc58a9b677"
open_webui_deep_research_valves:
ENGINE_BASE_URL: "{{ open_webui_engine_base_url }}"
ENGINE_MODEL_ID: "{{ open_webui_engine_model_id }}"
@@ -115,6 +115,9 @@ open_webui_env:
# existed only in legacy versions and is gone in v0.13.3.
ENABLE_WEB_SEARCH: "True"
WEB_SEARCH_ENGINE: searxng
# No Ollama on this host: without this the UI calls /ollama/api/version on
# every model-list open and surfaces HTTP 500 "could not connect to Ollama".
ENABLE_OLLAMA_API: "False"
# v0.13.3 strips any query string from the URL and sends q/format=json
# itself (retrieval/web/searxng.py), so the <query> placeholder form is
# correct.
@@ -21,22 +21,24 @@ except ImportError: # pragma: no cover - bs4 ist im OpenWebUI-Image vorhanden
BeautifulSoup = None
# NOTE: no str.format() on these prompts — the JSON braces {"queries": ...}
# would be parsed as format fields (KeyError). Use .replace() for {qpr}.
PLANNER_SYSTEM = (
"You are a research planner. Given the user's research question and the "
"conversation so far, produce a JSON object {\"queries\": [str, ...]} with "
"up to {qpr} concrete, diverse web search queries (English and the user's "
"language). Answer with JSON only, no prose."
"conversation so far, produce a JSON object with key \"queries\" holding a "
"list of up to {qpr} concrete, diverse web search queries (English and the "
"user's language). Answer with JSON only, no prose."
)
SYNTH_SYSTEM = (
"You are a research analyst. You receive search results and fetched page "
"excerpts, each tagged with a citation number [n]. Decide whether the "
"material answers the user's research question.\n"
"If more research is needed, answer JSON only: "
"{\"status\": \"continue\", \"next_queries\": [str, ...]} with up to {qpr} "
"follow-up queries that close the gaps.\n"
"If done, answer JSON only: {\"status\": \"done\", \"report\": \"<markdown "
"report in the user's language, cite claims with [n] markers>\"}.\n"
"If more research is needed, answer JSON only with keys \"status\" = "
"\"continue\" and \"next_queries\" = list of up to {qpr} follow-up queries "
"that close the gaps.\n"
"If done, answer JSON only with keys \"status\" = \"done\" and \"report\" = "
"markdown report in the user's language, citing claims with [n] markers.\n"
"Never invent citations; only use numbers of sources actually provided."
)
@@ -241,7 +243,7 @@ class Pipe:
# 1) planen (Runde 1) bzw. Luecken schliessen (Folgerunden)
if round_no == 1 or not queries:
plan_msgs = [
{"role": "system", "content": PLANNER_SYSTEM.format(qpr=v.QUERIES_PER_ROUND)},
{"role": "system", "content": PLANNER_SYSTEM.replace("{qpr}", str(v.QUERIES_PER_ROUND))},
*history,
{"role": "user", "content": f"Research question: {question}"},
]
@@ -279,7 +281,7 @@ class Pipe:
# 4) synthetisieren / Luecken bewerten
synth_msgs = [
{"role": "system", "content": SYNTH_SYSTEM.format(qpr=v.QUERIES_PER_ROUND)},
{"role": "system", "content": SYNTH_SYSTEM.replace("{qpr}", str(v.QUERIES_PER_ROUND))},
*history,
{"role": "user", "content": f"Research question: {question}\n\nSearch-result snippets:\n{snippets}\n\nFetched pages:\n{findings}"},
]
@@ -302,7 +304,7 @@ class Pipe:
# Max-Iterationen erreicht: trotzdem ein Report aus dem akkumulierten Material
if sources:
final_msgs = [
{"role": "system", "content": SYNTH_SYSTEM.format(qpr=0)},
{"role": "system", "content": SYNTH_SYSTEM.replace("{qpr}", "0")},
*history,
{"role": "user", "content": f"Research question: {question}\n\nAccumulated sources (iteration limit reached, write the best possible report now):\n" + "\n\n".join(
f"[{s['n']}] {s['title']} ({s['url']})" for s in sources
@@ -321,6 +323,9 @@ class Pipe:
return run()
# non-streaming: Generator konsumieren und als eine Completion zurückgeben
chunks: list[str] = []
async for chunk in run():
chunks.append(chunk)
try:
async for chunk in run():
chunks.append(chunk)
except Exception as e:
return f"Deep-Research-Fehler: {type(e).__name__}: {e}"
return "".join(chunks)