Phase 1 M6-R1 (Deep Research in OpenWebUI) + Phase 2 M8 geplant (GPT Researcher hinter IAP)
Phase 1 (GNAI-022, umgesetzt 14.11.2026 auf ghostnet-ki): - Pipe-Function gnai-deep-research (files/gnai-deep-research-pipe.py, sha256-gepinnt): iterativer plan->SearXNG->fetch->Synthese-Loop mit [n]-Zitationen, Engine direkt via http://llama-cpp:8080/v1, SSRF-Guard, Fetch-Caps, Streaming via event_emitter - open_webui-Rolle: DB-Seeding (function-Tabelle type=pipe, is_active, public read access_grant) + sha256-Verify + PIPE-OK-Verify; Defaults/Valves in defaults/main.yml - Verifikation: webui.yml produktiver Lauf ok=35 changed=3 failed=0, Health 200, zweiter Lauf idempotent changed=0; E2E via API (temp. Key) ist Betreiberschritt (GNAI-022 Abschnitt 5) Phase 2 (GNAI-023, M8 in GNAI-001): GPT Researcher (30.683 Sterne, v3.8.0) auf ghostnet-ki im Production-Netz, LLM via OPENAI_BASE_URL=llama.cpp, Suche ueber bestehende SearXNG; oeffentlich nur research.ghostnet.selfhost.eu via NPM + oauth2-proxy v7.15.5 (auth_request, Keycloak-OIDC Realm Ghost.net, Client gnai-research) — Härtungs-Checkliste in GNAI-023 Abschnitt 3/4. Doku: GNAI-000/GNAI-001/ai-README aktualisiert; GNAI-022 (Deep Research) und GNAI-023 (IAP-Plan) neu. Hinweis: roles/open_webui und ai/README enthalten neben diesen Aenderungen den bislang uncommitteten Theme-Stand (GNAI-021, produktiv live seit 14.11.2026). Link-Check: nur bekannte GNAI-021-Links broken (Datei fehlt im Working Tree). Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -9,3 +9,7 @@
|
||||
# .NET build artifacts (Ghostnet.Dashboard).
|
||||
bin/
|
||||
obj/
|
||||
|
||||
# Python
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
**Stand:** 2026-11-14
|
||||
|
||||
**Status:** Plattformgrundlage vorhanden; KI-Stack bis M6 produktiv (Testing/Production live auf `10.0.0.90`, Monitoring M1–M6 produktiv, öffentlicher Nutzerpfad `https://chat.ghostnet.selfhost.eu` live seit 11.11.2026 inklusive Websuche 12.11. und Theme 14.11.); Sicherheitsabschluss: Fail2Ban-Abnahme, hostunabhängige Backups/Restore, Keycloak-Stabilisierung, praktischer NPM-Rückfalltest und CT-104-Entfernung am 10.11.2026 geschlossen — WAN/IPv6-Fremdnetz-Rescan vom Hotspot, FRITZ!Box-Abgleich und FRITZ!Box-DNS-Rollback noch offen; M5-Delivery-Kette: statische CI, Runner (CT 116) und Branch-Protection seit 10.11.2026 umgesetzt, privilegierter Deployment-Runner noch offen; Encoding (M7) in Planung, Implementierung noch nicht begonnen
|
||||
**Status:** Plattformgrundlage vorhanden; KI-Stack bis M6 produktiv (Testing/Production live auf `10.0.0.90`, Monitoring M1–M6 produktiv, öffentlicher Nutzerpfad `https://chat.ghostnet.selfhost.eu` live seit 11.11.2026 inklusive Websuche 12.11. und Theme 14.11.); Sicherheitsabschluss: Fail2Ban-Abnahme, hostunabhängige Backups/Restore, Keycloak-Stabilisierung, praktischer NPM-Rückfalltest und CT-104-Entfernung am 10.11.2026 geschlossen — WAN/IPv6-Fremdnetz-Rescan vom Hotspot, FRITZ!Box-Abgleich und FRITZ!Box-DNS-Rollback noch offen; M5-Delivery-Kette: statische CI, Runner (CT 116) und Branch-Protection seit 10.11.2026 umgesetzt, privilegierter Deployment-Runner noch offen; Encoding (M7) in Planung, Implementierung noch nicht begonnen; Phase 1 M6-R1 (Deep Research in OpenWebUI, GNAI-022) in Umsetzung seit 14.11.; Phase 2 M8 (GPT Researcher hinter oauth2-proxy/IAP, GNAI-023) geplant
|
||||
|
||||
Dieses Dokument ist der zentrale Einstieg, nicht das technische Nachweisprotokoll.
|
||||
Details, historische Laufdaten und Bedienverfahren stehen ausschließlich in den
|
||||
@@ -53,6 +53,8 @@ jeweiligen Fachdokumenten. Die priorisierte weitere Umsetzung beschreibt der
|
||||
| [GNAI-010](platform/llm-server/ai/GNAI-010-TECH_Llama-Serving.md) | technische Sollkonfiguration des Testing-Servings |
|
||||
| [GNAI-020](platform/llm-server/ai/GNAI-020-TECH_OpenWebUI-WebSearch.md) | Websuche in OpenWebUI (SearXNG kuratiert + Native/Agentic Mode, UI- und API-Pfade) |
|
||||
| [GNAI-021](platform/llm-server/ai/GNAI-021-TECH_OpenWebUI-Theme.md) | OpenWebUI-Theme „gnai-catppuccin-mocha" (GNMON-Farbschema) als Default, update-persistent via read-only custom.css-Mount |
|
||||
| [GNAI-022](platform/llm-server/ai/GNAI-022-TECH_OpenWebUI-DeepResearch.md) | Phase 1 (M6-R1): Deep Research im bestehenden OpenWebUI-Harness — Recherche, Pipe-Function `gnai-deep-research`, Betrieb |
|
||||
| [GNAI-023](platform/llm-server/ai/GNAI-023-PLAN_GPT-Researcher-IAP.md) | Phase 2 (M8): GPT Researcher hinter Identity-Aware Proxy (oauth2-proxy + NPM auth_request + Keycloak-OIDC) — Machbarkeit, Sicherheit, Härtung |
|
||||
| [LLM-Server-Host-Ansible](../llm-server/host/ansible/README.md) | ausführbare Host-/ROCm-Playbooks und Rollen für `10.0.0.90` |
|
||||
| [LLM-Stack-Ansible](../llm-server/llm/ansible/README.md) | ausführbares Ansible-Projekt für den LLM-Stack auf `10.0.0.90` (Production/Testing, Umschaltung, Backup) |
|
||||
| [Encoding-Ansible](../llm-server/encoding/ansible/README.md) | ausführbares Ansible-Projekt für den CPU-Encoding-Workload auf `10.0.0.90` |
|
||||
@@ -90,7 +92,7 @@ Hauptverzeichnisse `llm-server/host/` (Grundkonfiguration des Servers),
|
||||
| --- | --- | --- |
|
||||
| KI-Host | Debian 13.6, Deployment-Zugang, Podman 5.4.2, getrennte rootless Konten, Gerätezugriff für beide KI-Konten; IPv4-only (31.10., GNAI-002 6); Lüftersteuerungs-Dienst `gnai-gpu-fan-control` als Dauerlösung (05.11., GNAI-010 10.10); Backup/Restore praktisch belegt (06.11., GNAI-008 14.6) und Backup-Unit per `RequiresMountsFor` boot-sicher (Fix 09.11., GNAI-008 14.6/0.21); Host-Neustart mit automatischem Production-Recovery (06.11. und erneut 09.11.2026, GNAI-008 14.6) | Host-/Treiber-Upgradepfad |
|
||||
| GPU/ROCm | beide RX 6900 XT als `gfx1030`, `ROCm0` und `ROCm1` im gepinnten Testing-Image erkannt; Modellladen, Layer-Verteilung und reale Inferenz auf beiden GPUs; 64k- und 128k-Stabilität in Testing (GNAI-010 10.5–10.9); GPU-Sensoren im Monitoring mit Alarmgrenzen (GNMON-000 M4/M5, verifiziert 09.11.2026) | Hardware-Ursache des thermischen Defekts an Slot `03:00.0` (GNAI-010 10.10) — Lüfterkurven-Service überbrückt als Dauerlösung |
|
||||
| LLM-Serving | drei gepinnte Profile (Swift 1.0, Swift 1.5, Unsloth); Testing-Abnahme 64k/128k je Profil (GNAI-010 10.5–10.9); Production-Umgebung live mit Swift 1.5 Q6_K seit 06.11.2026 (Betreiberbeschluss 05.11., GNAI-009 10.4) inklusive Health, Alias und Inferenztest; exklusive Umschaltmechanik mit Recovery (GNAI-008 14.6, T1–T7; nach Neustart 09.11.2026 `gn_ai_active_env{env="production"}=1` verifiziert); **OpenWebUI v0.13.3 (digest-gepinnt) intern produktiv seit 10.11.2026** — Health 200, Model-Liste, reale Chat-Completion via OpenWebUI → llama.cpp (Rolle `open_webui`, Playbook `webui.yml`, Ingress `10.0.0.90:8081` nur von NPM, Split-DNS `chat.ghostnet.selfhost.eu` live). **Öffentlicher Nutzerpfad M6 live seit 11.11.2026:** `https://chat.ghostnet.selfhost.eu` (OpenWebUI v0.13.3, NPM → 10.0.0.90:8081, Keycloak-OIDC Client `gnai-openwebui` public+PKCE; Negativtests: 8081/Engine-Ports von außen geblockt, `/admin/` 403, keine AAAA; OIDC-Redirect-Kette verifiziert). **Websuche produktiv seit 12.11.2026 (GNAI-020):** SearXNG mit 43 kuratierten Engines (168 Ergebnisse/1,4 s), OpenWebUI Native/Agentic Mode (`search_web`/`fetch_url`, `ENABLE_WEB_SEARCH=True` + DB-Config-Sync), E2E-Tool-Loop via API mit Quellen verifiziert, NPM-Proxy-Timeouts chat.* 600 s gesetzt (12.11., GNAI-020 Abschnitt 6). **Theme „gnai-catppuccin-mocha" live seit 14.11.2026 (GNAI-021)**, update-persistent via read-only custom.css-Mount | LLM-Metriken jenseits `gn_ai_active_env`, Nutzerakzeptanzprüfung (GNAI-009 5.3), Lizenz-/Nutzungsrahmen-Nachweis vor externer Freigabe (GNAI-009 10.4), Rate-Limit-Doku, Betriebs-SOP, API-Key-Freigabe für Agenten (GNAI-001 M6) |
|
||||
| LLM-Serving | drei gepinnte Profile (Swift 1.0, Swift 1.5, Unsloth); Testing-Abnahme 64k/128k je Profil (GNAI-010 10.5–10.9); Production-Umgebung live mit Swift 1.5 Q6_K seit 06.11.2026 (Betreiberbeschluss 05.11., GNAI-009 10.4) inklusive Health, Alias und Inferenztest; exklusive Umschaltmechanik mit Recovery (GNAI-008 14.6, T1–T7; nach Neustart 09.11.2026 `gn_ai_active_env{env="production"}=1` verifiziert); **OpenWebUI v0.13.3 (digest-gepinnt) intern produktiv seit 10.11.2026** — Health 200, Model-Liste, reale Chat-Completion via OpenWebUI → llama.cpp (Rolle `open_webui`, Playbook `webui.yml`, Ingress `10.0.0.90:8081` nur von NPM, Split-DNS `chat.ghostnet.selfhost.eu` live). **Öffentlicher Nutzerpfad M6 live seit 11.11.2026:** `https://chat.ghostnet.selfhost.eu` (OpenWebUI v0.13.3, NPM → 10.0.0.90:8081, Keycloak-OIDC Client `gnai-openwebui` public+PKCE; Negativtests: 8081/Engine-Ports von außen geblockt, `/admin/` 403, keine AAAA; OIDC-Redirect-Kette verifiziert). **Websuche produktiv seit 12.11.2026 (GNAI-020):** SearXNG mit 43 kuratierten Engines (168 Ergebnisse/1,4 s), OpenWebUI Native/Agentic Mode (`search_web`/`fetch_url`, `ENABLE_WEB_SEARCH=True` + DB-Config-Sync), E2E-Tool-Loop via API mit Quellen verifiziert, NPM-Proxy-Timeouts chat.* 600 s gesetzt (12.11., GNAI-020 Abschnitt 6). **Theme „gnai-catppuccin-mocha" live seit 14.11.2026 (GNAI-021)**. **Deep Research (Phase 1, GNAI-022) deployt 14.11.2026:** Pipe `gnai-deep-research` (sha256-gepinnt, public read grant) im Model-Selector; iterativer plan→SearXNG→fetch→Synthese-Loop direkt auf der Engine, Verifikation ok + idempotent `changed=0` | LLM-Metriken jenseits `gn_ai_active_env`, Nutzerakzeptanzprüfung (GNAI-009 5.3), Lizenz-/Nutzungsrahmen-Nachweis vor externer Freigabe (GNAI-009 10.4), Rate-Limit-Doku, Betriebs-SOP, API-Key-Freigabe für Agenten (GNAI-001 M6), E2E-Research-Lauf durch Betreiber (GNAI-022 Abschnitt 5). **Phase 2 (M8) geplant (GNAI-023):** GPT Researcher hinter oauth2-proxy/IAP + NPM auth_request + Keycloak-OIDC |
|
||||
| Deployment | lokales Ansible-Control-Projekt und idempotente Hostrollen; Production-Inventar mit Referenz- und Rollback-Profil, `ai_environment_switch` und Backup-Timer deployt und abgenommen (GNAI-008 14.6); **M5-Fortschritt 10.11.2026:** statische CI (Gitea Actions, 4 Jobs) + repo-scoped Runner `ci-static-01` auf CT 116 + Branch-Protection `main` (required checks, 1 Approval) eingerichtet und per PR-Durchlauf bewiesen (GNAI-008 Abschnitt 12) | privilegierter Deployment-Runner mit Promotion-Tag-Freigabe, Secret-Store/-Rotation, getrennte Testing-/Production-Rechte, Secret-Scan über die Git-Historie (GNAI-008 Abschnitt 12, Fragen 3–5) |
|
||||
| VPN | wg-easy v15.4.0; einziger Peer `ghost-laptop` als Server Admin; native nftables-Zielpolicy und NAT, Legacy-Bereinigung, Fremdnetz-, Positiv-/Negativ-, Dienst- und LXC-Wiederanlauftests bestanden; CT 104 am 07.10.2026 als zwölftes Ziel praktisch abgenommen; WAN-Exposure-Erfassung 10.11.2026: nur TCP 80/443 offen, keine AAAA (GNAI-007 7); frischer Stop-Mode-vzdump + hostunabhängige Kopie auf `ghostnet-ki` am 10.11.2026 | Fremdnetz-WAN-Rescan vom Hotspot (UDP 51820, TCP-Portmatrix), FRITZ!Box-Forward-/IPv6-Abgleich, wg-easy-GUI-HTTPS und KI-Server-Test bei eingeschaltetem Host |
|
||||
| DNS / Pi-hole | CT 100 unter `10.0.0.14` mit digest-gepinntem Pi-hole 2026.09.0 als Podman-Quadlet; SSH/nftables, UDP/TCP-DNS, Split-DNS, Blocking/Allowlist, FRITZ!Box-Cutover, LXC-Reboot und Stop-Mode-Backup am 01.10.2026 abgenommen; Ansible-Projekt am 09.11.2026 adoptiert (ansible-deploy via pct; `site.yml`/`verify-production` `changed=0`) und Split-DNS-Record `mon.ghostnet.selfhost.eu → 10.0.0.10` live (verifiziert per `dig @10.0.0.14`); frischer Stop-Mode-vzdump + hostunabhängige Kopie auf `ghostnet-ki` + praktischer Restore-Test (CT 150) am 10.11.2026 (GNAI-012 10.2) | vollständige App-/OIDC-Regression, praktischer FRITZ!Box-Rollback, mobile DuckDuckGo-/IPv6-Strategie, WireGuard-Profile |
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
**Stand:** 2026-11-14
|
||||
|
||||
**Status:** Arbeitsgrundlage; M1 bis auf Fremdnetz-Rescan/FRITZ!Box-Rollback geschlossen (10.11.), M2–M4 abgenommen, M5 statische CI/Runner/Branch-Protection umgesetzt (10.11.), M6 öffentlich live seit 11.11. (inkl. Websuche 12.11., Theme 14.11.), M7 offen
|
||||
**Status:** Arbeitsgrundlage; M1 bis auf Fremdnetz-Rescan/FRITZ!Box-Rollback geschlossen (10.11.), M2–M4 abgenommen, M5 statische CI/Runner/Branch-Protection umgesetzt (10.11.), M6 öffentlich live seit 11.11. (inkl. Websuche 12.11., Theme 14.11.) — Phase 1 (M6-R1 Deep Research im bestehenden Harness) in Umsetzung seit 14.11.; M7 offen; M8 (Phase 2: GPT Researcher hinter Identity-Aware Proxy) recherchiert und geplant (GNAI-023)
|
||||
|
||||
**Referenzen:** [Projektstand](GNAI-000-DOC_Index.md), [Zielarchitektur](platform/llm-server/ai/GNAI-004-INFRA_Architecture.md), [Ansible-Plan](platform/llm-server/ai/GNAI-008-PLAN_Ansible-Deployment.md), [Modellbewertung](platform/llm-server/ai/GNAI-009-PLAN_Llama-Model-Evaluation.md), [`llama.cpp`-Sollkonfiguration](platform/llm-server/ai/GNAI-010-TECH_Llama-Serving.md)
|
||||
|
||||
@@ -216,6 +216,20 @@ Nutzerakzeptanzprüfung auf dem Siegerprofil (GNAI-009 5.3) sowie der
|
||||
Lizenz-/Nutzungsrahmen-Nachweis (GNAI-009 10.4 — vor der externen Freigabe
|
||||
gefordert, als abgeschlossen noch nicht dokumentiert).
|
||||
|
||||
**Arbeitspaket M6-R1 — Deep Research im bestehenden Harness (Phase 1,
|
||||
umgesetzt 14.11.2026, Details GNAI-022):** Recherche vom 14.11.2026 ergab,
|
||||
dass kein zweiter Harness nötig ist, solange OpenWebUI selbst den
|
||||
Research-Loop fährt: native agentic Web-Search ist produktiv (GNAI-020),
|
||||
dazu eine Pipe-Function `gnai-deep-research` (iterativer
|
||||
plan→search→fetch→synthesize-Loop mit zitiertem Markdown-Report), geseeded
|
||||
per `open_webui`-Rolle in `webui.db` (sha256-gepinnt, idempotent, public read
|
||||
grant, Valves `SEARXNG_URL=http://searxng:8080`, Engine direkt via
|
||||
`http://llama-cpp:8080/v1`). Verifikation 14.11.: `webui.yml` produktiver Lauf
|
||||
`ok=35 changed=3 failed=0`, DB-Verify PIPE-OK, Health 200, zweiter Lauf
|
||||
`changed=0`. **Abnahme:** Function aktiv und im Model-Selector sichtbar
|
||||
(erfüllt); E2E-Research-Lauf via API mit Quellen durch den Betreiber mit
|
||||
temporärem API-Key noch offen (GNAI-022 Abschnitt 5).
|
||||
|
||||
**Ergebnis:** Genau ein klar definierter, authentifizierter Nutzerpfad ist
|
||||
öffentlich nutzbar; Backend- und Managementports bleiben intern.
|
||||
|
||||
@@ -244,6 +258,42 @@ LLM-Betrieb nicht.
|
||||
und unter gleichzeitiger Inferenzlast testen;
|
||||
- erst danach Zeitplan, Queue, Benachrichtigung und Nutzer-SOP freigeben.
|
||||
|
||||
### Meilenstein 8 – Zweiten Research-Harness hinter Identity-Aware Proxy (Phase 2)
|
||||
|
||||
**Status: recherchiert und geplant 14.11.2026 (GNAI-023), Umsetzung ausstehend.**
|
||||
|
||||
**Ergebnis:** GPT Researcher läuft als zweiter Harness auf `ghostnet-ki` im
|
||||
Production-Netz (Engine via `http://llama-cpp:8080/v1`, LLM-Konfig über
|
||||
`OPENAI_BASE_URL`), öffentlich nur über NPM hinter einem Identity-Aware
|
||||
Proxy.
|
||||
|
||||
- Harness-Wahl (Recherche 14.11., GNAI-023): GPT Researcher
|
||||
(`assafelovic/gpt-researcher`, 30.683 Sterne, v3.8.0 09.11.2026,
|
||||
Apache-2.0) — reiner Research-Agent, llama.cpp über custom
|
||||
`OPENAI_BASE_URL` (dokumentiert), Websuche über die bestehende
|
||||
SearXNG-Instanz (custom retriever, kein externer API-Key). DeerFlow
|
||||
(85.330 Sterne) bleibt Alternative für Multi-Agent/Sandboxes, ist aber
|
||||
kein reiner Research-Harness und hat kein natives Keycloak-OIDC-Setup so
|
||||
direkt wie der IAP-Pfad unten.
|
||||
- Identity-Aware Proxy: **oauth2-proxy v7.15.5** (provider `oidc` /
|
||||
`keycloak-oidc` gegen Keycloak Realm Ghost.net) hinter NPM (CT 103) via
|
||||
nginx `auth_request`-Subrequest (`/oauth2/auth`, 202 = erlaubt); NPM-vHost
|
||||
`research.ghostnet.selfhost.eu` mit Custom-Config (Advanced) für
|
||||
`auth_request` + interne `location /oauth2/`. oauth2-proxy selbst ohne
|
||||
öffentlichen Port (eigenes Podman-Netz auf CT 103 oder eigener LXC).
|
||||
- Härtung (GNAI-023 Abschnitt 4): cookie-secret 32B random, cookie-secure/
|
||||
httponly/samesite, PKCE (v7 default), `--email-domain`/`--whitelist-domain`,
|
||||
Gruppen/Rollen aus Keycloak-claim (`--allowed-group` +
|
||||
`--oidc-groups-claim`), skip-auth nur für `/ping`/ACME, internes TLS bzw.
|
||||
loopback-only, Secrets als Podman-Secrets, Fail2Ban-Jail auf oauth2-proxy-
|
||||
Logs, Session-Store, Rate-Limits, 2FA-Pflicht im Keycloak-Realm.
|
||||
- Abnahme: unauth 302→Keycloak, auth 200, Backend-Ports von außen geblockt,
|
||||
Gruppen-Negativtest, Logout, Idempotenz.
|
||||
|
||||
**Fertig, wenn:** GPT Researcher hinter dem IAP produktiv erreichbar ist,
|
||||
Keycloak-Gruppen die Nutzung steuern und Negativtests (direkte IP/Port,
|
||||
Bypass-Header) scheitern.
|
||||
|
||||
### Stand 14.11.2026
|
||||
|
||||
- **M1 weitgehend geschlossen (10.11.2026):** Fail2Ban-Funktionsabnahme,
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
# Technischer Arbeitsentwurf
|
||||
|
||||
**Dokumenten-ID:** GNAI-022-TECH
|
||||
**Titel:** Deep Research im bestehenden OpenWebUI-Harness (Roadmap Phase 1, M6-R1)
|
||||
**Stand:** 2026-11-14
|
||||
**Status:** deployt und verifiziert (Playbook ok, Idempotenz `changed=0`, DB-Verify PIPE-OK, Health 200); E2E-Research-Lauf durch den Betreiber mit temporärem API-Key noch offen (Abschnitt 5)
|
||||
**Referenzen:** [Roadmap M6/M6-R1](../../../GNAI-001-PLAN_Project-Roadmap.md), [DOC-Index](../../../GNAI-000-DOC_Index.md), [GNAI-020](GNAI-020-TECH_OpenWebUI-WebSearch.md) (Websuche/SearXNG), Rolle `llm-server/llm/ansible/roles/open_webui/` (README, `files/gnai-deep-research-pipe.py`), OpenWebUI v0.13.3 (digest-gepinnt), OpenWebUI docs (Pipe Function, Reserved Arguments, Stand 2026-11-14)
|
||||
|
||||
> Dieses Dokument beschreibt, warum Phase 1 **ohne zweiten Harness**
|
||||
auskommt, wie die Pipe-Function `gnai-deep-research` aufgebaut ist und wie
|
||||
sie betrieben/verifiziert wird.
|
||||
|
||||
---
|
||||
|
||||
## Änderungsverlauf
|
||||
|
||||
| Datum | Version | Autor | Beschreibung |
|
||||
| --- | --- | --- | --- |
|
||||
| 2026-11-14 | 0.1 | spektr / Mistral Vibe | Erstfassung: Recherche-Ergebnis, Pipe-Implementierung, Deployment, Verifikation, Betriebs-Hinweise |
|
||||
|
||||
---
|
||||
|
||||
## 1. Entscheidung (Betreiber, 14.11.2026)
|
||||
|
||||
Ein zweiter Harness (DeerFlow, GPT Researcher, Vane) wird für ausführliche
|
||||
Recherchen **nicht** zusätzlich betrieben, solange OpenWebUI den Research-Loop
|
||||
selbst fährt. Phase 1 = OpenWebUI-native Agentic Web Search (bereits produktiv,
|
||||
GNAI-020) plus eine dedizierte Pipe-Function für iterative Deep Research.
|
||||
Phase 2 (GPT Researcher hinter Identity-Aware Proxy) ist als M8 separat
|
||||
geplant (GNAI-023).
|
||||
|
||||
## 2. Recherche-Ergebnis (14.11.2026)
|
||||
|
||||
Marktübersicht Deep-Research-Harnesses (GitHub API 14.11.2026, Reddit
|
||||
r/LocalLLaMA/r/selfhosted, Vergleichsartikel Okt–Nov 2026):
|
||||
|
||||
- **DeerFlow** (bytedance) 85.330 Sterne, #1 GitHub Trending 28.02.2026 —
|
||||
Super-Agent-Harness (Sub-Agenten, Memory, Sandboxes, Skills); Research nur
|
||||
ein Skill; empfiehlt Cloud-Frontier-Modelle; OIDC vorhanden, llama.cpp als
|
||||
custom Provider möglich (dokumentiertes Qwen3.8-27B-llama.cpp-Setup).
|
||||
- **GPT Researcher** 30.683 Sterne, v3.8.0 (09.11.2026), Apache-2.0 — reiner
|
||||
Research-Agent, llama.cpp via custom `OPENAI_BASE_URL`; kein natives
|
||||
Keycloak-OIDC (eigener Login) → IAP nötig (Phase 2, GNAI-023).
|
||||
- **Vane** (ex-Perplexica, umbenannt 03/2026) ~36.700 Sterne — Answer-Engine,
|
||||
SearXNG gebundled, aber OSS single-user ohne Keycloak-SSO.
|
||||
- **AnythingLLM** 67.691 Sterne — Chat/RAG-Workspace, OSS **ohne** echtes OIDC
|
||||
(nur Simple-SSO-Passthrough; Keycloak nur Enterprise-Lizenz).
|
||||
- **LibreChat** 45.200 Sterne — Chat-UI, Keycloak-OIDC dokumentiert, aber
|
||||
kein Research-Harness.
|
||||
- Archiviert/gefroren: `langchain-ai/open_deep_research` (archiviert
|
||||
21.08.2026), STORM (main seit 30.09.2025 gefroren).
|
||||
- Community-Option in OpenWebUI: Function „Iterative Deep Research"
|
||||
(openwebui.com, OWUI v0.11+, braucht SearXNG) — openwebui.com war am
|
||||
14.11.2026 im System-Upgrade nicht erreichbar und der Code ist nicht auf
|
||||
GitHub gespiegelt; daher **eigene, auditierbare Pipe** (Abschnitt 3).
|
||||
|
||||
OpenWebUI selbst deckt den Research-Loop bereits ab: v0.13.3 mit Native
|
||||
Agentic Web Search (`search_web`/`fetch_url`, produktiv seit 12.11.2026,
|
||||
GNAI-020) und Pipe-Functions als eigene „Modelle" im Selector.
|
||||
|
||||
## 3. Implementierung: Pipe `gnai-deep-research`
|
||||
|
||||
Datei: `llm-server/llm/ansible/roles/open_webui/files/gnai-deep-research-pipe.py`,
|
||||
Content per sha256 gepinnt (`open_webui_deep_research_pipe_sha256`, nach jeder
|
||||
Code-Änderung neu berechnen). Die Rolle seedet die Function idempotent per
|
||||
sqlite in `webui.db` (Tabelle `function`: type `pipe`, `is_active=1`,
|
||||
`is_global=0`, Valves als JSON) und setzt einen public read `access_grant`
|
||||
(resource_type `model`, principal `user`/`*`) — dadurch erscheint
|
||||
`gnai-deep-research` im Model-Selector jedes authentifizierten OIDC-Users.
|
||||
|
||||
Loop (Valves konfigurierbar, Defaults in `defaults/main.yml`):
|
||||
|
||||
1. **Planen:** Engine-Call (direkt `POST {ENGINE_BASE_URL}/chat/completions`,
|
||||
`ENGINE_BASE_URL=http://llama-cpp:8080/v1`, `ENGINE_MODEL_ID` =
|
||||
Production-Profil) mit Planner-Prompt → JSON `{"queries": [...]}`.
|
||||
2. **Suchen:** SearXNG `GET {SEARXNG_URL}/search?q=…&format=json`
|
||||
(`SEARXNG_URL=http://searxng:8080`, die kuratierte Instanz aus GNAI-020).
|
||||
3. **Fetchen:** Top-Seiten per httpx, **SSRF-Guard** (nur http(s), DNS
|
||||
auflösen und private/loopback/link-local/reserved IPs verwerfen),
|
||||
Redirect-Chain max. 3 Hops mit Re-Validierung, Content-Type-Prüfung,
|
||||
Content-Cap (`FETCH_MAX_BYTES`), Timeout (`FETCH_TIMEOUT_S`).
|
||||
4. **Synthetisieren:** Engine bewertet Fundstellen → JSON
|
||||
`{"status":"continue","next_queries":[…]}` oder
|
||||
`{"status":"done","report":"…"}`; Zitationen als `[n]`, Quellenliste wird
|
||||
von der Pipe deterministisch angehängt. Abbruch nach `MAX_ITERATIONS`
|
||||
mit Best-possible-Report.
|
||||
5. **Streaming:** `__event_emitter__`-Statusmeldungen pro Runde; bei
|
||||
`stream:false` eine Gesamtresponse.
|
||||
|
||||
Keine externen API-Keys, keine Secrets im Code; `__user__`/`__metadata__`
|
||||
nach OWUI-v0.13.3 Reserved-Args (`user_prompt` lesen, History cappen).
|
||||
|
||||
## 4. Deployment-Verifikation (14.11.2026, Production-Inventar)
|
||||
|
||||
- `webui.yml --check --diff`: sauber.
|
||||
- Produktiver Lauf als `ansible-deploy`: `ok=35 changed=3 failed=0`
|
||||
(Pipe-Sync `CHANGED`, Unit-Restart, Staging); Health `/health` 200;
|
||||
Engine-Model-List aus dem Container ok.
|
||||
- DB-Verify im Playbook: `PIPE-OK` (function row type=pipe active, Valves mit
|
||||
SEARXNG_URL, public read grant vorhanden); sha256-Verify gegen Pin ok.
|
||||
- Idempotenz: zweiter Lauf `ok=33 changed=0`.
|
||||
- Read-only gegen `ghostnet-ki` (ghost-agent): Health über `10.0.0.90:8081`
|
||||
bestätigt (Playbook-uri), Container/Unit aktiv.
|
||||
|
||||
## 5. Betrieb und E2E-Abnahme
|
||||
|
||||
- **UI (Browser, OIDC):** Model-Selector → `gnai-deep-research` wählen,
|
||||
Frage stellen; Statusmeldungen streamen, Report mit Quellenliste.
|
||||
- **API:** `POST /api/chat/completions` mit `"model": "gnai-deep-research"`.
|
||||
- **E2E-Betreiberschritt (noch offen, analog GNAI-020 Abschnitt 4e/g):**
|
||||
temporären API-Key im Admin-UI anlegen (`auth.enable_api_keys` temporär
|
||||
true), dann z. B.
|
||||
`curl -X POST https://chat.ghostnet.selfhost.eu/api/chat/completions -H "Authorization: Bearer sk-…" -d '{"model":"gnai-deep-research","messages":[{"role":"user","content":"…"}],"stream":false}'`,
|
||||
Report auf Quellen prüfen; danach Test-Chat löschen, Key entfernen,
|
||||
`auth.enable_api_keys` wieder false. NPM-Proxy-Timeouts 600 s auf
|
||||
`chat.*` sind seit 12.11. gesetzt (GNAI-020 Abschnitt 6) — lange
|
||||
Research-Loops sind damit abgedeckt.
|
||||
- Rate-Limit-Doku und LLM-Metriken im Monitoring bleiben M6-Restpunkte
|
||||
(GNAI-001 M6).
|
||||
|
||||
## 6. Sicherheit
|
||||
|
||||
- Pipe-Code läuft serverseitig in OpenWebUI (OWUI-Warnung: Functions sind
|
||||
arbitrary Python — daher sha256-Pin, Review vor Änderung, nur Admin legt
|
||||
Functions an).
|
||||
- SSRF-Guard siehe Abschnitt 3; SearXNG/Engine werden nicht über den Guard
|
||||
gefiltert (interne Aliase), nur externe Fetches.
|
||||
- Keine Secrets in Code/Valves/Repo; Ingress unverändert: `10.0.0.90:8081`
|
||||
nur von NPM, öffentlich nur `chat.ghostnet.selfhost.eu` mit Keycloak-OIDC.
|
||||
|
||||
## 7. Offen
|
||||
|
||||
1. E2E-Research-Lauf durch den Betreiber (Abschnitt 5).
|
||||
2. Qualität des 27B-Produktionsprofils (Swift 1.5 Q6_K) im langen Research-Loop
|
||||
gegen Frontier — Nutzerakzeptanz (GNAI-009 5.3) mitnehmen.
|
||||
3. Option: später Community-Function „Iterative Deep Research" (openwebui.com)
|
||||
evaluieren, sobald die Community-API wieder erreichbar ist; eigene Pipe
|
||||
bleibt Referenz.
|
||||
4. Phase 2 (GPT Researcher + IAP) siehe GNAI-023.
|
||||
@@ -0,0 +1,132 @@
|
||||
# Plan
|
||||
|
||||
**Dokumenten-ID:** GNAI-023-PLAN
|
||||
**Titel:** Phase 2 (M8): GPT Researcher hinter Identity-Aware Proxy — Machbarkeit, Sicherheit, Härtung
|
||||
**Stand:** 2026-11-14
|
||||
**Status:** Recherche abgeschlossen und Architektur vorentschieden; Umsetzung ausstehend (kein produktiver Eingriff ohne Betreiber-Go)
|
||||
**Referenzen:** [Roadmap M8](../../../GNAI-001-PLAN_Project-Roadmap.md), [DOC-Index](../../../GNAI-000-DOC_Index.md), [GNAI-006](../../proxmox-server/lxc/ct-103-reverse-proxy/GNAI-006-SEC_Reverse-Proxy.md) (NPM CT 103), [GNAI-016](../../proxmox-server/lxc/ct-102-keycloak/GNAI-016-PLAN_Keycloak-Ansible-Rebuild.md) (Keycloak CT 102), [GNAI-022](GNAI-022-TECH_OpenWebUI-DeepResearch.md) (Phase 1), oauth2-proxy docs v7.15.x, NPM docs, GPT Researcher docs (Stand 14.11.2026)
|
||||
|
||||
> Dieses Dokument fasst die Recherche vom 14.11.2026 zusammen und legt die
|
||||
> geplante Architektur für einen zweiten Research-Harness hinter einem
|
||||
> Identity-Aware Proxy fest. Es ist Planungsstand, noch keine
|
||||
> Installationsanleitung.
|
||||
|
||||
---
|
||||
|
||||
## 1. Zielbild
|
||||
|
||||
```
|
||||
Internet → NPM (CT 103, 443) → auth_request-Subrequest an oauth2-proxy
|
||||
→ bei 202: proxy_pass an GPT Researcher (ghostnet-ki, LAN-Port nur von NPM)
|
||||
→ bei 401/403: 302 zu Keycloak-OIDC (Realm Ghost.net, Client gnai-research)
|
||||
```
|
||||
|
||||
- Harness: **GPT Researcher** (`assafelovic/gpt-researcher`, 30.683 Sterne,
|
||||
v3.8.0 vom 09.11.2026, Apache-2.0) auf `ghostnet-ki` im Production-Netz
|
||||
(neues Quadlet-Set, Rolle `gpt_researcher` unter `llm-server/llm/ansible/`).
|
||||
- LLM: bestehende Engine via `OPENAI_BASE_URL=http://llama-cpp:8080/v1`
|
||||
(llama.cpp, kein Auth — Container-intern), `OPENAI_API_KEY` = Placeholder;
|
||||
`FAST_LLM`/`SMART_LLM` = Production-Profil-Alias. Custom OpenAI-compatible
|
||||
Endpoints werden von GPT Researcher unterstützt (dokumentiert; externe
|
||||
Praxistests 2026 bestätigen llama.cpp-Anbindung über `OPENAI_BASE_URL`).
|
||||
- Websuche: bestehende SearXNG-Instanz (GNAI-020) als custom retriever —
|
||||
kein externer Search-API-Key; Fallback DuckDuckGo (keyless).
|
||||
- Ingress: `research.ghostnet.selfhost.eu` (Split-DNS CT 100 → 10.0.0.10,
|
||||
NPM-vHost → `10.0.0.90:<port>`), abgesichert durch oauth2-proxy.
|
||||
|
||||
## 2. Machbarkeit Identity-Aware Proxy hinter NPM
|
||||
|
||||
**Ja, mit oauth2-proxy v7.15.5 (aktuell 2026) + nginx `auth_request`:**
|
||||
|
||||
- oauth2-proxy stellt `/oauth2/auth` bereit: Subrequest antwortet **202** bei
|
||||
gültiger Session, **401/403** sonst — genau das nginx-`auth_request`-Modul.
|
||||
- NPM (2.15.1, OpenResty) erlaubt pro Proxy-Host im **Advanced**-Tab arbitrary
|
||||
nginx-Snippet; dort wird eingebaut:
|
||||
```nginx
|
||||
location /oauth2/ { internal; proxy_pass http://<oauth2-proxy-intern>:4180; ... }
|
||||
location / { auth_request /oauth2/auth; error_page 401 =302 https://auth…/login…;
|
||||
proxy_pass http://10.0.0.90:<port>; ... }
|
||||
location = /oauth2/auth { internal; proxy_pass …; proxy_pass_request_body off;
|
||||
proxy_set_header Content-Length ""; proxy_set_header X-Original-URI $request_uri; }
|
||||
```
|
||||
(exaktes Snippet beim Rollout gegen oauth2-proxy-docs prüfen).
|
||||
- oauth2-proxy selbst **ohne** öffentlichen Port: eigenes Podman-Netz auf
|
||||
CT 103 (nur NPM-Container dürfen es erreichen) oder eigener kleiner LXC
|
||||
(z. B. CT 117) — Entscheidung beim Rollout; Trennung vom NPM-Container ist
|
||||
die härtere Variante (CT 117 empfohlen).
|
||||
- Keycloak: oauth2-proxy v7.15 unterstützt Provider `oidc` (issuer discovery)
|
||||
und `keycloak-oidc`; Issuer
|
||||
`https://auth.ghostnet.selfhost.eu/realms/Ghost.net`. Keycloak-Client
|
||||
`gnai-research` (confidential; Secret als Podman-Secret, nie in Git),
|
||||
Redirect-URI `https://research.ghostnet.selfhost.eu/oauth2/callback`,
|
||||
Scopes `openid email profile groups`.
|
||||
- Alternativen geprüft und verworfen: **Authelia** (eigener IdP + 2FA;
|
||||
überdimensioniert, da Keycloak bereits IdP ist), **Pomerium** (Zero-Trust-
|
||||
Gateway, eigener IdP-Fokus), AnythingLLM/Vane (kein OSS-Keycloak), DeerFlow
|
||||
(Harness statt IAP; OIDC vorhanden, aber als zweiter Harness mit eigener
|
||||
Auth-Domäne ungünstiger als IAP vor einem beliebigen Backend).
|
||||
|
||||
## 3. Sicherheitsmodell
|
||||
|
||||
- **Vertrauensanker ist Keycloak, nicht der Client:** oauth2-proxy validiert
|
||||
Session serverseitig (signiertes/verschlüsseltes Cookie oder Redis-Session);
|
||||
`auth_request` prüft serverseitig — ein von außen gefälschter
|
||||
`X-Forwarded-User`-Header ist wirkungslos, weil oauth2-proxy nur seinem
|
||||
eigenen Cookie vertraut und `--reverse-proxy=true` nur hinter dem internen
|
||||
NPM erreichbar ist.
|
||||
- **Gruppen/Rollen:** Keycloak-Realm-Rollen per Mapper auf den `groups`-Claim
|
||||
legen; oauth2-proxy `--oidc-groups-claim=groups` +
|
||||
`--allowed-group=gnai-research-user` (Realm-Rolle anlegen, User zuweisen).
|
||||
Negativtest: User ohne Rolle → 403.
|
||||
- **Registrierung/Whitelist:** `--email-domain` (oder `--allowed-email`),
|
||||
`--whitelist-domain=.ghostnet.selfhost.eu`, `--skip-provider-button`.
|
||||
- **Session-Härtung:** `--cookie-secret` (32 B random, Podman-Secret),
|
||||
`--cookie-secure=true`, `--cookie-httponly=true`, `--cookie-samesite=lax`
|
||||
(auth_request-Flow braucht Lax), Cookie-Name mit `__Host-`-Präfix wo
|
||||
möglich, `--cookie-expire`/`--cookie-refresh` begrenzen, optional Redis-
|
||||
Session-Store für Multi-Replica.
|
||||
- **Flow-Härtung:** PKCE (v7 default), CSRF-State-Cookie, `--skip-auth-regex`
|
||||
nur für `^/ping$` und ACME-Pfade, kein Open Redirect (redirect-URL strikt
|
||||
auf die eigene Domain), `--pass-access-token=false` unless GPT Researcher
|
||||
ihn braucht, `--set-xauthrequest` nur wenn das Backend X-User/X-Email
|
||||
auswerten soll.
|
||||
- **Transport:** oauth2-proxy nur auf loopback/internem Netz; NPM→oauth2-
|
||||
proxy über Podman-Netz Klartext ok (intern), Client→NPM TLS (LE).
|
||||
- **Logging/Monitoring:** oauth2-proxy-Logs (auth failures) in Loki
|
||||
(GNMON), Fail2Ban-Jail auf CT 103 für wiederholte 401/403 auf
|
||||
`/oauth2/start`, Rate-Limit am IAP, Metriken-Endpunkt nur intern.
|
||||
- **Backend-Härtung:** GPT-Researcher-Port auf `10.0.0.90` per
|
||||
`gnmon_firewall`-Rolle nur von `10.0.0.10` (NPM) freigeben — direkter
|
||||
LAN-Zugriff ohne IAP dann unmöglich; WAN-Scan muss den Port geblockt
|
||||
zeigen. 2FA-Pflicht im Keycloak-Realm (required action) für die
|
||||
research-Rolle.
|
||||
|
||||
## 4. Härtungs-Checkliste für den Rollout (Abnahme)
|
||||
|
||||
1. unauth Request auf `research.ghostnet.selfhost.eu` → 302 zu Keycloak
|
||||
(nicht 200/502).
|
||||
2. auth Request (Keycloak-Login, Rolle `gnai-research-user`) → 200.
|
||||
3. User ohne Rolle → 403 (Gruppen-Negativtest).
|
||||
4. Direkter Zugriff auf `10.0.0.90:<port>` vom LAN (ohne NPM) → geblockt
|
||||
(nftables); vom WAN → geblockt (Port nicht offen).
|
||||
5. Gefälschte `X-Forwarded-User`/`X-Forwarded-Email`-Header von außen →
|
||||
keine Auth-Bypass (auth_request gewinnt).
|
||||
6. `/oauth2/sign_out` → Session invalidiert, erneuter Zugriff → 302.
|
||||
7. Keycloak-Client-Secret als Podman-Secret; Secret-Scan (CI `secret-scan`)
|
||||
grün; kein Secret in Git/Logs.
|
||||
8. Fail2Ban-Jail greift bei wiederholten Fehl-Logins.
|
||||
9. Idempotenz: Playbook zweiter Lauf `changed=0`; CT-103-Ansible-Drift
|
||||
`changed=0`.
|
||||
10. E2E: Research-Auftrag in GPT Researcher läuft gegen llama.cpp +
|
||||
SearXNG, Report mit Quellen; NPM-Timeouts für lange Läufe gesetzt.
|
||||
|
||||
## 5. Offene Entscheidungen vor dem Rollout
|
||||
|
||||
- oauth2-proxy-Platzierung: Podman-Netz auf CT 103 vs. eigener LXC CT 117
|
||||
(Empfehlung: CT 117, sauberere Fehlerdomäne).
|
||||
- NPM-vHost + auth_request-Snippet per CT-103-Ansible automatisieren oder
|
||||
Betreiber-Schritt (Vorschlag: Ansible, damit `verify-production` greift).
|
||||
- GPT-Researcher-Port und Ressourcen-Limits (CPU/RAM, parallel zur Engine
|
||||
exklusiv — gleicher Host, Wartungsfenster beachten).
|
||||
- Ob DeerFlow später als dritter Harness mit Sandboxes ergänzt wird
|
||||
(Community-Favorit), hängt von den Erfahrungen mit GPT Researcher ab.
|
||||
@@ -15,6 +15,9 @@ Video-Encoding-Workload besitzt einen
|
||||
| [GNAI-009](GNAI-009-PLAN_Llama-Model-Evaluation.md) | Modellbewertung für Swift/Unsloth; Betreiberbeschluss 05.11.2026: Swift 1.5 Q6_K als Production-Profil (Abschnitt 10.4) |
|
||||
| [GNAI-010](GNAI-010-TECH_Llama-Serving.md) | technische Sollkonfiguration für die Modellprofile auf rootless `llama.cpp` mit ROCm; Testing abgenommen (10.5–10.10), Production live seit 06.11.2026 |
|
||||
| [GNAI-020](GNAI-020-TECH_OpenWebUI-WebSearch.md) | Websuche in OpenWebUI: SearXNG mit kuratierten Engines + Native/Agentic Mode (`search_web`/`fetch_url`), UI- und API-Betrieb (Path A/B), produktiv verifiziert seit 12.11.2026 |
|
||||
| [GNAI-021](GNAI-021-TECH_OpenWebUI-Theme.md) | OpenWebUI-Theme „gnai-catppuccin-mocha" + Favicons, update-persistent via read-only Mounts, live seit 14.11.2026 |
|
||||
| [GNAI-022](GNAI-022-TECH_OpenWebUI-DeepResearch.md) | Phase 1 (M6-R1): Deep Research im bestehenden OpenWebUI-Harness — Pipe `gnai-deep-research` (sha256-gepinnt), Deployment verifiziert 14.11.2026 |
|
||||
| [GNAI-023](GNAI-023-PLAN_GPT-Researcher-IAP.md) | Phase 2 (M8): GPT Researcher hinter Identity-Aware Proxy (oauth2-proxy + NPM auth_request + Keycloak-OIDC) — Machbarkeit, Sicherheit, Härtung |
|
||||
|
||||
Der übergreifende Projektstand steht im
|
||||
[zentralen Dokumentationsindex](../../../GNAI-000-DOC_Index.md).
|
||||
|
||||
@@ -43,3 +43,17 @@ Embedding-Modell wird nicht benötigt.
|
||||
Lang laufende Research-Loops (mehrere search_web/fetch_url-Runden) brauchen
|
||||
auf dem NPM-Proxy-Host `chat.ghostnet.selfhost.eu` erhöhte Proxy-Timeouts
|
||||
(siehe GNAI-020 Abschnitt NPM).
|
||||
|
||||
## Deep Research (GNAI-022, M6-R1 / Phase 1)
|
||||
|
||||
Die Pipe-Function `gnai-deep-research` (`files/gnai-deep-research-pipe.py`,
|
||||
Content per sha256 gepinnt) wird idempotent in die `function`-Tabelle von
|
||||
`webui.db` geseeded (type `pipe`, `is_active=1`) und erhält einen public read
|
||||
`access_grant` (resource_type `model`) — dadurch erscheint sie im
|
||||
Model-Selector als „gnai-deep-research". Valves (Engine, SearXNG, Iterationen,
|
||||
Fetch-Limits) liegen in `defaults/main.yml`. Der Loop ruft die Engine direkt
|
||||
über `http://llama-cpp:8080/v1` (kein OWUI-Auth nötig) und SearXNG über
|
||||
`http://searxng:8080`; Seiten-Fetch mit SSRF-Guard (keine privaten/loopback/
|
||||
link-local IPs), Redirect-Chain mit Re-Validierung, Content-Cap und Timeout.
|
||||
Nach jeder Code-Änderung `sha256sum` neu berechnen und
|
||||
`open_webui_deep_research_pipe_sha256` aktualisieren.
|
||||
|
||||
@@ -33,6 +33,25 @@ open_webui_engine_model_id: swift-1.5-qwen3.8-27b-q6k
|
||||
# with a public read grant. API callers pass this id in `tool_ids`.
|
||||
open_webui_web_search_tool_id: gnai-web-search
|
||||
|
||||
# Deep-Research pipe (GNAI-022, M6-R1 / Roadmap Phase 1): iterative
|
||||
# plan->search->fetch->synthesize loop exposed as a pipe "model" in the
|
||||
# model selector. Seeded idempotently into webui.db; content pinned by
|
||||
# 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_valves:
|
||||
ENGINE_BASE_URL: "{{ open_webui_engine_base_url }}"
|
||||
ENGINE_MODEL_ID: "{{ open_webui_engine_model_id }}"
|
||||
SEARXNG_URL: "http://searxng:8080"
|
||||
MAX_ITERATIONS: 5
|
||||
QUERIES_PER_ROUND: 4
|
||||
RESULTS_PER_QUERY: 6
|
||||
PAGES_PER_ROUND: 5
|
||||
FETCH_TIMEOUT_S: 12.0
|
||||
FETCH_MAX_BYTES: 200000
|
||||
TEMPERATURE: 0.3
|
||||
|
||||
# Engine endpoint inside the shared Production network. llama.cpp itself
|
||||
# has no auth; OpenWebUI just needs a non-empty key value, supplied via a
|
||||
# Podman secret (never in git).
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
"""
|
||||
title: gnai-deep-research
|
||||
author: ghostnet.ai
|
||||
description: Iterativer Deep-Research-Loop (plan -> SearXNG-Suche -> Seiten-Fetch -> Synthese mit Quellenangaben) als Pipe-Model. Ruft die Production-Engine direkt ueber das interne Netz (llama.cpp, kein Host-Port) und die bestehende SearXNG-Instanz. Läuft serverseitig in OpenWebUI (v0.13.3).
|
||||
license: MIT
|
||||
"""
|
||||
|
||||
import ipaddress
|
||||
import json
|
||||
import re
|
||||
import socket
|
||||
from typing import Any, AsyncIterator
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import httpx
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
try:
|
||||
from bs4 import BeautifulSoup
|
||||
except ImportError: # pragma: no cover - bs4 ist im OpenWebUI-Image vorhanden
|
||||
BeautifulSoup = None
|
||||
|
||||
|
||||
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."
|
||||
)
|
||||
|
||||
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"
|
||||
"Never invent citations; only use numbers of sources actually provided."
|
||||
)
|
||||
|
||||
|
||||
class Pipe:
|
||||
class Valves(BaseModel):
|
||||
ENGINE_BASE_URL: str = Field(
|
||||
default="http://llama-cpp:8080/v1",
|
||||
description="OpenAI-kompatibles Engine-Ende im Production-Netz (llama.cpp, ohne Auth).",
|
||||
)
|
||||
ENGINE_MODEL_ID: str = Field(
|
||||
default="swift-1.5-qwen3.8-27b-q6k",
|
||||
description="Modell- alias auf der Engine (muss zum Model-Store passen).",
|
||||
)
|
||||
SEARXNG_URL: str = Field(
|
||||
default="http://searxng:8080",
|
||||
description="Interne SearXNG-Instanz (Egress-Netz).",
|
||||
)
|
||||
MAX_ITERATIONS: int = Field(default=5, ge=1, le=10)
|
||||
QUERIES_PER_ROUND: int = Field(default=4, ge=1, le=8)
|
||||
RESULTS_PER_QUERY: int = Field(default=6, ge=1, le=20)
|
||||
PAGES_PER_ROUND: int = Field(default=5, ge=1, le=10)
|
||||
FETCH_TIMEOUT_S: float = Field(default=12.0, gt=0, le=60)
|
||||
FETCH_MAX_BYTES: int = Field(default=200_000, ge=10_000, le=1_000_000)
|
||||
TEMPERATURE: float = Field(default=0.3, ge=0, le=2)
|
||||
|
||||
def __init__(self):
|
||||
self.valves = self.Valves()
|
||||
|
||||
# ---------- helpers ----------
|
||||
|
||||
@staticmethod
|
||||
def _user_text(body: dict, metadata: dict | None) -> str:
|
||||
md = metadata or {}
|
||||
prompt = md.get("user_prompt")
|
||||
if prompt:
|
||||
return str(prompt)
|
||||
for msg in reversed(body.get("messages", [])):
|
||||
if msg.get("role") != "user":
|
||||
continue
|
||||
content = msg.get("content")
|
||||
if isinstance(content, str):
|
||||
return content
|
||||
if isinstance(content, list):
|
||||
return "\n".join(
|
||||
p.get("text", "") for p in content if isinstance(p, dict) and p.get("type") == "text"
|
||||
)
|
||||
return ""
|
||||
|
||||
@staticmethod
|
||||
def _history(body: dict) -> list[dict]:
|
||||
out = []
|
||||
for msg in body.get("messages", []):
|
||||
if msg.get("role") not in ("user", "assistant"):
|
||||
continue
|
||||
content = msg.get("content")
|
||||
if isinstance(content, list):
|
||||
content = "\n".join(
|
||||
p.get("text", "") for p in content if isinstance(p, dict) and p.get("type") == "text"
|
||||
)
|
||||
if isinstance(content, str) and content:
|
||||
out.append({"role": msg["role"], "content": content})
|
||||
return out[-8:]
|
||||
|
||||
@staticmethod
|
||||
def _extract_json(text: str) -> dict:
|
||||
text = text.strip()
|
||||
m = re.search(r"\{.*\}", text, re.DOTALL)
|
||||
if m:
|
||||
try:
|
||||
return json.loads(m.group(0))
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
try:
|
||||
return json.loads(text)
|
||||
except json.JSONDecodeError:
|
||||
return {}
|
||||
|
||||
@staticmethod
|
||||
def _safe_url(url: str) -> bool:
|
||||
"""SSRF-Schutz: nur http(s), keine privaten/loopback/reserved IPs."""
|
||||
try:
|
||||
p = urlparse(url)
|
||||
if p.scheme not in ("http", "https") or not p.hostname:
|
||||
return False
|
||||
if p.hostname.lower() in ("localhost", "127.0.0.1", "::1"):
|
||||
return False
|
||||
infos = socket.getaddrinfo(p.hostname, None)
|
||||
for info in infos:
|
||||
ip = ipaddress.ip_address(info[4][0])
|
||||
if ip.is_private or ip.is_loopback or ip.is_link_local or ip.is_multicast or ip.is_reserved:
|
||||
return False
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
async def _engine(self, client: httpx.AsyncClient, messages: list[dict]) -> str:
|
||||
resp = await client.post(
|
||||
f"{self.valves.ENGINE_BASE_URL.rstrip('/')}/chat/completions",
|
||||
json={
|
||||
"model": self.valves.ENGINE_MODEL_ID,
|
||||
"messages": messages,
|
||||
"temperature": self.valves.TEMPERATURE,
|
||||
"stream": False,
|
||||
},
|
||||
timeout=180.0,
|
||||
)
|
||||
resp.raise_for_status()
|
||||
data = resp.json()
|
||||
return data["choices"][0]["message"]["content"] or ""
|
||||
|
||||
async def _search(self, client: httpx.AsyncClient, query: str) -> list[dict]:
|
||||
try:
|
||||
resp = await client.get(
|
||||
f"{self.valves.SEARXNG_URL.rstrip('/')}/search",
|
||||
params={"q": query, "format": "json", "safesearch": "1"},
|
||||
timeout=20.0,
|
||||
)
|
||||
resp.raise_for_status()
|
||||
results = resp.json().get("results", [])
|
||||
return [
|
||||
{"url": r.get("url", ""), "title": r.get("title", ""), "snippet": r.get("content", "")}
|
||||
for r in results
|
||||
if r.get("url")
|
||||
][: self.valves.RESULTS_PER_QUERY]
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
async def _fetch(self, client: httpx.AsyncClient, url: str) -> str:
|
||||
"""holt eine Seite mit Redirect-Chain (jede Hop neu validiert) und Content-Cap."""
|
||||
current = url
|
||||
for _ in range(3):
|
||||
if not self._safe_url(current):
|
||||
return ""
|
||||
try:
|
||||
resp = await client.get(
|
||||
current,
|
||||
follow_redirects=False,
|
||||
timeout=self.valves.FETCH_TIMEOUT_S,
|
||||
headers={"User-Agent": "gnai-deep-research/0.1 (+selfhosted research pipe)"},
|
||||
)
|
||||
except Exception:
|
||||
return ""
|
||||
if resp.is_redirect:
|
||||
location = resp.headers.get("location", "")
|
||||
if not location:
|
||||
return ""
|
||||
from urllib.parse import urljoin
|
||||
|
||||
current = urljoin(current, location)
|
||||
continue
|
||||
if resp.status_code != 200:
|
||||
return ""
|
||||
ctype = resp.headers.get("content-type", "")
|
||||
if "html" not in ctype and "text" not in ctype and "json" not in ctype and "xml" not in ctype:
|
||||
return ""
|
||||
raw = b""
|
||||
async for chunk in resp.aiter_bytes(65536):
|
||||
raw += chunk
|
||||
if len(raw) > self.valves.FETCH_MAX_BYTES:
|
||||
raw = raw[: self.valves.FETCH_MAX_BYTES]
|
||||
break
|
||||
text = raw.decode("utf-8", errors="replace")
|
||||
if "html" in ctype and BeautifulSoup is not None:
|
||||
text = BeautifulSoup(text, "html.parser").get_text("\n")
|
||||
text = re.sub(r"\n{3,}", "\n\n", text)
|
||||
return text[: self.valves.FETCH_MAX_BYTES]
|
||||
return ""
|
||||
|
||||
async def _emit(self, emitter: Any, text: str) -> None:
|
||||
if emitter is not None:
|
||||
try:
|
||||
await emitter({"type": "status", "data": {"description": text, "done": False}})
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# ---------- pipe ----------
|
||||
|
||||
async def pipe(
|
||||
self,
|
||||
body: dict,
|
||||
__metadata__: dict | None = None,
|
||||
__user__: dict | None = None,
|
||||
__event_emitter__: Any = None,
|
||||
) -> AsyncIterator[str] | str:
|
||||
v = self.valves
|
||||
question = self._user_text(body, __metadata__)
|
||||
if not question:
|
||||
return "No user question found in the request."
|
||||
history = self._history(body)
|
||||
if history and history[-1]["role"] == "user" and history[-1]["content"] == question:
|
||||
history = history[:-1]
|
||||
|
||||
sources: list[dict] = [] # {n, url, title}
|
||||
seen_urls: set[str] = set()
|
||||
|
||||
async def run() -> AsyncIterator[str]:
|
||||
nonlocal sources
|
||||
async with httpx.AsyncClient(timeout=30.0) as client:
|
||||
queries: list[str] = []
|
||||
for round_no in range(1, v.MAX_ITERATIONS + 1):
|
||||
# 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)},
|
||||
*history,
|
||||
{"role": "user", "content": f"Research question: {question}"},
|
||||
]
|
||||
await self._emit(__event_emitter__, f"Runde {round_no}: plane Suchanfragen …")
|
||||
plan = self._extract_json(await self._engine(client, plan_msgs))
|
||||
queries = [q for q in plan.get("queries", []) if isinstance(q, str)][: v.QUERIES_PER_ROUND]
|
||||
if not queries:
|
||||
queries = [question]
|
||||
|
||||
# 2) suchen
|
||||
await self._emit(__event_emitter__, f"Runde {round_no}: {len(queries)} Suchanfragen …")
|
||||
found: list[dict] = []
|
||||
for q in queries:
|
||||
for r in await self._search(client, q):
|
||||
if r["url"] not in seen_urls:
|
||||
seen_urls.add(r["url"])
|
||||
r["query"] = q
|
||||
found.append(r)
|
||||
|
||||
# 3) Top-Seiten fetchen (mit SSRF-Guard)
|
||||
pages: list[dict] = []
|
||||
for r in found[: v.PAGES_PER_ROUND]:
|
||||
await self._emit(__event_emitter__, f"Lese {r['url'][:100]} …")
|
||||
text = await self._fetch(client, r["url"])
|
||||
if text:
|
||||
sources.append({"n": len(sources) + 1, "url": r["url"], "title": r["title"] or r["url"]})
|
||||
pages.append({"n": sources[-1]["n"], "url": r["url"], "title": sources[-1]["title"], "text": text[:8000]})
|
||||
|
||||
findings = "\n\n".join(
|
||||
f"[{p['n']}] {p['title']} ({p['url']})\n{p['text']}" for p in pages
|
||||
) or "(keine neuen Seiteninhalte)"
|
||||
snippets = "\n".join(
|
||||
f"- {r['title']}: {r['snippet'][:200]} ({r['url']})" for r in found[:10]
|
||||
)
|
||||
|
||||
# 4) synthetisieren / Luecken bewerten
|
||||
synth_msgs = [
|
||||
{"role": "system", "content": SYNTH_SYSTEM.format(qpr=v.QUERIES_PER_ROUND)},
|
||||
*history,
|
||||
{"role": "user", "content": f"Research question: {question}\n\nSearch-result snippets:\n{snippets}\n\nFetched pages:\n{findings}"},
|
||||
]
|
||||
await self._emit(__event_emitter__, f"Runde {round_no}: synthetisiere Zwischenergebnis …")
|
||||
verdict = self._extract_json(await self._engine(client, synth_msgs))
|
||||
if verdict.get("status") == "done" and verdict.get("report"):
|
||||
report = str(verdict["report"])
|
||||
if sources:
|
||||
report += "\n\n## Quellen\n" + "\n".join(
|
||||
f"[{s['n']}] {s['title']} — {s['url']}" for s in sources
|
||||
)
|
||||
yield report
|
||||
return
|
||||
queries = [
|
||||
q for q in verdict.get("next_queries", []) if isinstance(q, str)
|
||||
][: v.QUERIES_PER_ROUND]
|
||||
if not queries:
|
||||
break
|
||||
|
||||
# Max-Iterationen erreicht: trotzdem ein Report aus dem akkumulierten Material
|
||||
if sources:
|
||||
final_msgs = [
|
||||
{"role": "system", "content": SYNTH_SYSTEM.format(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
|
||||
)},
|
||||
]
|
||||
verdict = self._extract_json(await self._engine(client, final_msgs))
|
||||
report = verdict.get("report") or "(kein Report erzeugt)"
|
||||
report += "\n\n## Quellen\n" + "\n".join(
|
||||
f"[{s['n']}] {s['title']} — {s['url']}" for s in sources
|
||||
)
|
||||
yield report
|
||||
return
|
||||
yield "Recherche ohne brauchbare Quellen. Bitte Frage präzisieren."
|
||||
|
||||
if body.get("stream"):
|
||||
return run()
|
||||
# non-streaming: Generator konsumieren und als eine Completion zurückgeben
|
||||
chunks: list[str] = []
|
||||
async for chunk in run():
|
||||
chunks.append(chunk)
|
||||
return "".join(chunks)
|
||||
@@ -420,6 +420,121 @@
|
||||
changed_when: false
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Stage the deep-research pipe source and verify its pinned sha256
|
||||
# GNAI-022 (M6-R1 Phase 1): the pipe content is pinned by sha256 so a
|
||||
# silent upstream edit can never reach the server; the DB sync task below
|
||||
# reports the real change.
|
||||
block:
|
||||
- name: Stage the pipe source
|
||||
ansible.builtin.copy:
|
||||
src: files/gnai-deep-research-pipe.py
|
||||
dest: /tmp/gnai-deep-research-pipe.py
|
||||
mode: "0600"
|
||||
changed_when: false
|
||||
|
||||
- name: Verify the pipe sha256 against the pinned value
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- sha256sum
|
||||
- /tmp/gnai-deep-research-pipe.py
|
||||
register: open_webui_pipe_hash
|
||||
changed_when: false
|
||||
failed_when: >-
|
||||
open_webui_pipe_hash.stdout.split()[0] != open_webui_deep_research_pipe_sha256
|
||||
|
||||
- name: Ensure the deep-research pipe exists, is active and publicly readable in OpenWebUI
|
||||
# Pipe functions (type='pipe') appear as models in the selector with
|
||||
# id=function.id; the public read grant on resource_type='model' makes it
|
||||
# visible to every authenticated OIDC user. Valves are stored as plain
|
||||
# JSON (no secret fields). Idempotent; touches only the app DB.
|
||||
ansible.builtin.shell: |
|
||||
set -euo pipefail
|
||||
python3 - "{{ open_webui_data_dir }}/webui.db" \
|
||||
/tmp/gnai-deep-research-pipe.py \
|
||||
'{{ open_webui_deep_research_valves | to_json }}' \
|
||||
"{{ open_webui_deep_research_function_id }}" <<'PYEOF'
|
||||
import json, sqlite3, sys, time, uuid
|
||||
db, content_path, valves_raw, fn_id = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]
|
||||
content = open(content_path).read()
|
||||
valves = json.loads(valves_raw)
|
||||
meta = json.dumps({"description": "Iterativer Deep-Research-Loop (plan -> SearXNG -> fetch -> Synthese) auf der Production-Engine. GNAI-022 / GNAI-001 M6-R1."})
|
||||
now = int(time.time())
|
||||
con = sqlite3.connect(db)
|
||||
changed = False
|
||||
row = con.execute("select content, valves, meta, type, is_active, is_global from function where id=?", (fn_id,)).fetchone()
|
||||
if not row:
|
||||
con.execute(
|
||||
"insert into function (id, version_id, user_id, name, type, content, meta, valves, is_active, is_global, updated_at, created_at)"
|
||||
" values (?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||
(fn_id, str(uuid.uuid4()), "openwebui", "gnai-deep-research", "pipe", content, meta, json.dumps(valves), 1, 0, now, now),
|
||||
)
|
||||
changed = True
|
||||
elif (
|
||||
row[0] != content
|
||||
or json.loads(row[1] or "{}") != valves
|
||||
or row[2] != meta
|
||||
or row[3] != "pipe"
|
||||
or row[4] != 1
|
||||
or row[5] != 0
|
||||
):
|
||||
con.execute(
|
||||
"update function set content=?, valves=?, meta=?, type='pipe', is_active=1, is_global=0, updated_at=?, version_id=? where id=?",
|
||||
(content, json.dumps(valves), meta, now, str(uuid.uuid4()), fn_id),
|
||||
)
|
||||
changed = True
|
||||
grant = con.execute(
|
||||
"select id from access_grant where resource_type='model' and resource_id=? and principal_type='user' and principal_id='*' and permission='read'",
|
||||
(fn_id,),
|
||||
).fetchone()
|
||||
if not grant:
|
||||
con.execute(
|
||||
"insert into access_grant (id, resource_type, resource_id, principal_type, principal_id, permission, created_at)"
|
||||
" values (?,?,?,?,?,?,?)",
|
||||
(str(uuid.uuid4()), "model", fn_id, "user", "*", "read", now),
|
||||
)
|
||||
changed = True
|
||||
con.commit()
|
||||
print("CHANGED" if changed else "UNCHANGED")
|
||||
PYEOF
|
||||
args:
|
||||
executable: /bin/bash
|
||||
when: not ansible_check_mode
|
||||
register: open_webui_pipe_sync
|
||||
changed_when: open_webui_pipe_sync.stdout_lines | first == 'CHANGED'
|
||||
|
||||
- name: Verify the deep-research pipe row and grant in webui.db
|
||||
ansible.builtin.shell: |
|
||||
set -euo pipefail
|
||||
python3 - "{{ open_webui_data_dir }}/webui.db" "{{ open_webui_deep_research_function_id }}" <<'PYEOF'
|
||||
import json, sqlite3, sys
|
||||
con = sqlite3.connect(sys.argv[1])
|
||||
fn_id = sys.argv[2]
|
||||
row = con.execute("select type, is_active, valves from function where id=?", (fn_id,)).fetchone()
|
||||
assert row, "function row missing"
|
||||
assert row[0] == "pipe" and row[1] == 1, "pipe not active"
|
||||
valves = json.loads(row[2])
|
||||
assert valves.get("SEARXNG_URL"), "SEARXNG_URL valve missing"
|
||||
grant = con.execute(
|
||||
"select count(*) from access_grant where resource_type='model' and resource_id=? and principal_type='user' and principal_id='*' and permission='read'",
|
||||
(fn_id,),
|
||||
).fetchone()[0]
|
||||
assert grant == 1, "public read grant missing"
|
||||
print("PIPE-OK")
|
||||
PYEOF
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: open_webui_pipe_verify
|
||||
changed_when: false
|
||||
failed_when: "'PIPE-OK' not in open_webui_pipe_verify.stdout"
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Remove the staged pipe source
|
||||
ansible.builtin.file:
|
||||
path: /tmp/gnai-deep-research-pipe.py
|
||||
state: absent
|
||||
changed_when: false
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Wait for the OpenWebUI health endpoint
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ open_webui_host_addr }}:{{ open_webui_host_port }}/health"
|
||||
|
||||
Reference in New Issue
Block a user