M6: Websuche produktiv (SearXNG kuratiert + Native/Agentic Mode) — GNAI-020 (#16)
Co-authored-by: vibe-agent <vibe-agent@ghostnet.local>
This commit was merged in pull request #16.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Ghostnet.AI – Dokumentationsindex und Projektstand
|
||||
|
||||
**Stand:** 2026-11-10
|
||||
**Stand:** 2026-11-12
|
||||
|
||||
**Status:** Plattformgrundlage vorhanden; KI-Stack intern bis M4 abgenommen (Testing und Production live auf `10.0.0.90`, Monitoring produktiv); Sicherheitsabschluss: Fail2Ban-Abnahme und hostunabhängige Backups/Restore am 10.11.2026 geschlossen, WAN/IPv6-Fremdnetz-Rescan, NPM-Rückfalltest CT 104 und FRITZ!Box-Rollback noch offen; externe KI-Freigabe (M6) offen
|
||||
|
||||
@@ -51,6 +51,7 @@ jeweiligen Fachdokumenten. Die priorisierte weitere Umsetzung beschreibt der
|
||||
| [GNAI-008](platform/llm-server/ai/GNAI-008-PLAN_Ansible-Deployment.md) | detaillierter Ansible-/Gitea-Planungsstand und Implementierungshistorie |
|
||||
| [GNAI-009](platform/llm-server/ai/GNAI-009-PLAN_Llama-Model-Evaluation.md) | reproduzierbarer Modellvergleich |
|
||||
| [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) |
|
||||
| [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` |
|
||||
@@ -88,11 +89,11 @@ 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) | LLM-Metriken jenseits `gn_ai_active_env`, Nutzerakzeptanzprüfung (GNAI-009 5.3). **Ö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) |
|
||||
| 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) | LLM-Metriken jenseits `gn_ai_active_env`, Nutzerakzeptanzprüfung (GNAI-009 5.3). **Ö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) |
|
||||
| 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) | statische CI, Runner, geschützte Freigaben und automatisierter Rollback über die Delivery-Kette |
|
||||
| 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 |
|
||||
| Reverse Proxy | CT-103-Zugänge, SSH-/Firewall-Baseline, Reboot und lokales Backup abgenommen; NPM 2.15.1 routet öffentlichen OIDC- und internen Admin-vHost getrennt; öffentliche Keycloak-Administration liefert 403; vollständiger Ansible-Sollzustand importiert und adoptiert (07.11.2026; preflight/verify-production/`site.yml --check` am 09.11.2026 ohne Befund, `changed=0`); Fail2Ban-Funktionsabnahme (Jails, kontrollierter Ban/Unban, nftables-Nachweis, Dienstneustart, LXC-Reboot) am 10.11.2026 bestanden, frischer Rollback-vzdump + hostunabhängige Kopie auf `ghostnet-ki` (GNAI-006 10/12) | Fremdnetz-WAN-Rescan (Hotspot) und FRITZ!Box-Abgleich; NPM-Proxyhost `mon.ghostnet.selfhost.eu` für das Monitoring-Dashboard (M6) |
|
||||
| Reverse Proxy | CT-103-Zugänge, SSH-/Firewall-Baseline, Reboot und lokales Backup abgenommen; NPM 2.15.1 routet öffentlichen OIDC- und internen Admin-vHost getrennt; öffentliche Keycloak-Administration liefert 403; vollständiger Ansible-Sollzustand importiert und adoptiert (07.11.2026; preflight/verify-production/`site.yml --check` am 09.11.2026 ohne Befund, `changed=0`); Fail2Ban-Funktionsabnahme (Jails, kontrollierter Ban/Unban, nftables-Nachweis, Dienstneustart, LXC-Reboot) am 10.11.2026 bestanden, frischer Rollback-vzdump + hostunabhängige Kopie auf `ghostnet-ki` (GNAI-006 10/12); **12.11.2026: NPM-Proxyhost `chat.ghostnet.selfhost.eu` mit `proxy_read_timeout`/`proxy_send_timeout` 600 s für LLM-Research-Loops** (Betreiber-Schritt, GNAI-020 Abschnitt 6) | Fremdnetz-WAN-Rescan (Hotspot) und FRITZ!Box-Abgleich; NPM-Proxyhost `mon.ghostnet.selfhost.eu` für das Monitoring-Dashboard (M6) |
|
||||
| Keycloak | CT 102 unter `10.0.0.4` reproduzierbar per Ansible aufgebaut; gepinntes Keycloak 26.2.4 und PostgreSQL 16.15, Restore von CT 104, Container-/DB-Härtung, NPM-Cutover, interner Adminzugang, öffentliche Admin-Sperre, realer Vaultwarden-OIDC-Login und LXC-Neustart abgenommen; Stabilisierungsphase + praktischer NPM-Rückfalltest auf CT 104 am 10.11.2026 bestanden, CT 104 danach nach Betreiberfreigabe entfernt (GNAI-016 Phase F); Ansible-Drift CT 102 `changed=0`; frischer Stop-Mode-vzdump + hostunabhängige Kopie auf `ghostnet-ki` am 10.11.2026 | Betriebs-/Backup-/Restore-SOP |
|
||||
| Encoding | Konto, Pfade, eigener rootless Store und CPU-Isolation per Ansible verwaltet und verifiziert; NFS-Mount `/var/lib/ghostnet-pipeline` aktiv (verifiziert 09.11.2026); Planungsabschluss 19.10.2026 (Pipeline GNENC-002, Speicher auf CT-101); Monitoring-Anbindung umgesetzt (GNMON-000 M1–M5) | Implementierung (Images, Quadlets, Skripte, Worker); Lasttest und Limit-Feintuning; SMB-Output-Pickup als geschlossener Ablauf |
|
||||
| Monitoring | M1–M6 produktiv auf `10.0.0.90` (System-Scope, Konten `gn-monitor` 986 / `gn-dashboard` 984): node_exporter + AMD-Textfile-Collector, VictoriaMetrics, Loki + Alloy, vmalert + Alertmanager (inkl. `gnmon-ai`/`GnAiEnvironmentDown`), Dashboard **v0.3.2 öffentlich über `https://mon.ghostnet.selfhost.eu`** (NPM CT-103 ID 14, LE-TLS; Keycloak-OIDC Realm Ghost.net, Client `gnai-dashboard`, Rollen `gnai-dashboard-user`/`-admin`; 8080 per nftables nur von 10.0.0.10; E2E inkl. 403-Negativtest und WebSocket-Circuit bestanden 09.11.2026, GNMON-000 M6) | echter SMTP-Versand, LLM-Metriken jenseits `gn_ai_active_env`, Retention-Feintuning, externer WireGuard-Zugriff auf mon (DNS/TLS öffentlich, praktisch ungetestet) |
|
||||
|
||||
@@ -182,8 +182,13 @@ Health 200, interne E2E-Inferenz bestanden. Negativ: WAN-Scan nur 80/443,
|
||||
8081/Engine-Ports geblockt, `/admin/` 403, keine AAAA. Reale Browser-Anmeldung des Betreibers am 11.11.2026 bestanden (OIDC-Session
|
||||
`oidc` in OpenWebUI-DB, User `ma-koenig@gmx.net` provisioniert); öffentlicher
|
||||
Chat-Test via `https://chat.ghostnet.selfhost.eu/api/chat/completions` → 200
|
||||
mit Token-Usage. Offen: Rate-Limit-Doku, LLM-Metriken im Monitoring,
|
||||
Betriebs-SOP.
|
||||
mit Token-Usage. **Websuche live seit 12.11.2026 (GNAI-020):** SearXNG mit
|
||||
kuratierten Engines + OpenWebUI Native/Agentic Mode, E2E-Tool-Loop via API
|
||||
(server-seitig, mit Quellen) verifiziert; Workspace-Tool `gnai-web-search`
|
||||
für API-Agenten via `tool_ids` geseeded; NPM-Proxy-Timeouts auf `chat.*`
|
||||
(600 s) für lange Research-Loops durch Betreiber gesetzt (12.11.2026,
|
||||
GNAI-020 Abschnitt 6). Offen: Rate-Limit-Doku, LLM-Metriken im Monitoring,
|
||||
Betriebs-SOP, API-Key-Freigabe für Agenten (`auth.enable_api_keys`).
|
||||
|
||||
**Ergebnis:** Genau ein klar definierter, authentifizierter Nutzerpfad ist
|
||||
öffentlich nutzbar; Backend- und Managementports bleiben intern.
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
# Technischer Arbeitsentwurf
|
||||
|
||||
**Dokumenten-ID:** GNAI-020-TECH
|
||||
**Titel:** Websuche in OpenWebUI (SearXNG, self-hosted) — kuratierte Engines + Native/Agentic Mode
|
||||
**Stand:** 2026-11-12
|
||||
**Status:** produktiv und E2E-verifiziert (Abschnitt 4), vom Betreiber im UI bestätigt (12.11.2026); Betreiber-Entscheidung 2026-11-12: Option A (self-hosted SearXNG, kein externer API-Key)
|
||||
**Referenzen:** [Roadmap M6](../../../GNAI-001-PLAN_Project-Roadmap.md), [DOC-Index](../../../GNAI-000-DOC_Index.md), Rollen `llm-server/llm/ansible/roles/web_search/` und `roles/open_webui/` (READMEs), OpenWebUI-Doku Stand 2026-11-10 (docs.openwebui.com)
|
||||
|
||||
> Dieses Dokument beschreibt den technischen Sollzustand und den belegten
|
||||
> Betriebsstand der Websuche in OpenWebUI.
|
||||
|
||||
---
|
||||
|
||||
## Änderungsverlauf
|
||||
|
||||
| Datum | Version | Autor | Beschreibung |
|
||||
| --- | --- | --- | --- |
|
||||
| 2026-11-12 | 0.1 | spektr / Mistral Vibe | Erstfassung: Befunde, Umsetzung (Rollen `web_search`/`open_webui`), Verifikation, Betriebs-Pfade |
|
||||
| 2026-11-12 | 0.2 | spektr / Mistral Vibe | Befund h) ergänzt: `meta.defaultFeatureIds` war leer — neue UI-Chats starteten ohne Web-Search-Toggle; Model-Sync setzt jetzt `defaultFeatureIds=["web_search"]`; E2E-Nachweis nur mit Builtin-Tools; NPM-Timeout-Schritt (Abschnitt 6) durch Betreiber ausgeführt und als erledigt markiert |
|
||||
|
||||
---
|
||||
|
||||
## 1. Entscheidung
|
||||
|
||||
Betreiberentscheid 2026-11-12: Agenten und Nutzer von `https://chat.ghostnet.selfhost.eu`
|
||||
sollen harness-grade Websuche bekommen (mehrstufiger search→fetch→search-Loop mit
|
||||
zitierbaren Quellen), self-hosted über die bestehende SearXNG-Instanz im
|
||||
Egress-Netz — **kein externer Search-API-Key** (Option A aus der Recherche vom
|
||||
2026-11-11; externe Anbieter Exa/Tavily/Brave bleiben als Erweiterung offen, Abschnitt 7).
|
||||
|
||||
Recherche-Ergebnis (November 2026): OpenWebUI v0.13.3 (neuestes Release, 2026-11-08)
|
||||
bietet zwei Modi — Legacy-RAG (unsupported) und **Native/Agentic Mode** (Default seit
|
||||
v0.10) mit den Builtin-Tools `search_web` (Snippets, kein RAG/Embedding) und
|
||||
`fetch_url` (ganze Seite, zitierfähig). Harnesses (Claude Code, OpenCode, LM Studio
|
||||
Bionic) arbeiten prinzipiell gleich: das Modell entscheidet selbst, wann es sucht und
|
||||
liest. Externe APIs (Benchmark openbenchmarks 2026-10-21): Exa 99,3 % / Tavily 97,7 %
|
||||
Accuracy — SearXNG ist qualitativ von den Upstream-Engines abhängig, bleibt aber die
|
||||
Privacy-konforme Wahl.
|
||||
|
||||
## 2. Befunde: warum die bisherige Implementierung nicht funktionierte
|
||||
|
||||
a) **`ENABLE_WEB_SEARCH` fehlte** — in v0.13.3 ist der Default **False**
|
||||
(`config.py:1169`). Ohne dieses Gate werden `search_web`/`fetch_url` nie injiziert.
|
||||
b) **Persistierte Config schlägt Env** — OpenWebUI legt jeden ConfigVar in der
|
||||
`config`-Tabelle ab und die DB gewinnt über die Env-Variable. Die DB enthielt
|
||||
`web.search.enable=false`, `web.search.engine=""`, `web.search.searxng_query_url=""`
|
||||
(Seeding beim ersten Start) — die Env-Werte der Rolle griffen faktisch nicht.
|
||||
c) **`ENABLE_RAG_WEB_SEARCH=True` war in v0.13.3 eine tote Variable** — der
|
||||
Legacy-RAG-Pfad existiert nicht mehr; ein Embedding-Download beim ersten
|
||||
Suchlauf (SentenceTransformers all-MiniLM-L6-v2, ~500 MB) war ein Hänge-Kandidat.
|
||||
d) **SearXNG lief mit allen 123 Default-Engines** (`use_default_settings: true`),
|
||||
inkl. key-loser API-Engines und Warez-/Adult-Indizes — langsam, CAPTCHA/429-Bans
|
||||
bis 15 Tage (`suspended_times`).
|
||||
e) **API vs. UI**: Builtin-Tools werden nur für UI-Requests (mit `session_id`)
|
||||
injiziert (`utils/middleware.py:2070`); reine API-Requests ohne `chat_id`+`id`
|
||||
bekommen rohe `tool_calls` zurück (Client-seitige Ausführung). Server-seitiger
|
||||
Tool-Loop für API-Agenten: **Path A** (Abschnitt 5).
|
||||
f) `SEARXNG_QUERY_URL` mit `<query>`-Placeholder ist korrekt: v0.13.3 streicht den
|
||||
Query-String und sendet `q`/`format=json` selbst (`retrieval/web/searxng.py`).
|
||||
SearXNG braucht `search.formats: [html, json]` (sonst 403).
|
||||
g) SearXNG durchsucht ohne `categories`-Parameter nur die Kategorie `general`
|
||||
(`webadapter.py get_selected_categories`) — IT-/Science-/News-Engines wären ohne
|
||||
Override nie angesprungen.
|
||||
h) **Neuer Chat ohne Web-Search-Toggle**: `meta.defaultFeatureIds` des Modells war
|
||||
leer — in v0.13.3 startet ein neuer UI-Chat mit `webSearchEnabled` nur dann, wenn
|
||||
`defaultFeatureIds` `"web_search"` enthält (`Chat.svelte defaultFeature()`).
|
||||
Behebung: Model-Sync setzt `defaultFeatureIds=["web_search"]` (verifiziert per
|
||||
`/api/models`: `info.meta.defaultFeatureIds = ['web_search']`).
|
||||
|
||||
## 3. Umsetzung (Ansible, Playbook `webui.yml`, Inventory `production`)
|
||||
|
||||
### 3.1 Rolle `web_search` (SearXNG)
|
||||
|
||||
- `templates/settings.yml.j2`: `use_default_settings.engines.keep_only` mit 43
|
||||
kuratierten Engines (Web: bing, brave, duckduckgo, startpage, mojeek, qwant,
|
||||
swisscows, mwmbl, marginalia; News: bing/brave./ddg/mojeek/startpage/swisscows/yahoo
|
||||
news, reuters, tagesschau; Wikis: wikipedia, wikidata; IT/Doku: github,
|
||||
github code, gitlab, stackoverflow, askubuntu, superuser, arch linux wiki, pypi,
|
||||
npm, crates.io, repology, docker hub, microsoft learn, mdn, hackernews; Science/
|
||||
Security: arxiv, semantic scholar, pubmed, europepmc, openalex, crossref,
|
||||
springer nature, national vulnerability database). Engine-Namen exakt wie in der
|
||||
Default-`settings.yml` des gepinnten Images (Commit `626105eec`). Jeder Engine per
|
||||
`engines:`-Override auf `disabled: false` + `categories: [general]` (siehe 2g).
|
||||
- `outgoing.request_timeout: 2.5`, `max_request_timeout: 8` (Default 3.0/10.0);
|
||||
`search.suspended_times` auf 60–600 s verkürzt (Datacenter-Egress landet sonst
|
||||
tagelang auf Bans); `limiter: false`, `formats: [html, json]` wie gehabt.
|
||||
- Playbook-Probe verschärft: JSON-API muss echte `results` liefern (nicht nur HTTP 200).
|
||||
|
||||
### 3.2 Rolle `open_webui`
|
||||
|
||||
- Env (Quadlet): `ENABLE_WEB_SEARCH=True`, `WEB_SEARCH_ENGINE=searxng`,
|
||||
`SEARXNG_QUERY_URL=http://searxng:8080/search?q=<query>`, `WEB_SEARCH_RESULT_COUNT=8`,
|
||||
`WEB_SEARCH_CONCURRENT_REQUESTS=4`, `WEB_FETCH_MAX_CONTENT_LENGTH=100000`,
|
||||
`USER_AGENT=<realistischer Browser-String>` (Bot-Detection des Web-Loaders);
|
||||
`ENABLE_RAG_WEB_SEARCH` entfernt (2c).
|
||||
- Quadlet-Template: `Environment="KEY=value"` quoting (sonst splittet systemd Werte
|
||||
mit Leerzeichen — betraf u. a. `OAUTH_SCOPES=openid email profile`).
|
||||
- DB-Sync (idempotent, sqlite wie beim Model-Sync):
|
||||
- `config`-Zeilen `web.search.enable=true`, `web.search.engine="searxng"`,
|
||||
`web.search.searxng_query_url`, `web.search.result_count=8`,
|
||||
`web.search.concurrent_requests=4`, `web.fetch.max_content_length=100000`
|
||||
(korrigiert 2b; Config wird pro Request aus der DB gelesen, kein Restart nötig).
|
||||
- Model-Row `swift-1.5-qwen3.8-27b-q6k`: `meta.capabilities.web_search=true`,
|
||||
`meta.builtinTools.web_search=true` und `meta.defaultFeatureIds=["web_search"]`
|
||||
(Defaults sind true, aber explizit — ein UI-Toggle darf API-Agenten nicht
|
||||
unbemerkt kappen; `defaultFeatureIds` schaltet den Web-Search-Toggle in neuen
|
||||
UI-Chats default an, siehe 2h). Native Function Calling ist seit v0.10 Default,
|
||||
`params` bleibt `{}`.
|
||||
- Workspace-Tool **`gnai-web-search`** (`files/gnai-web-search-tool.py` +
|
||||
`files/gnai-web-search-tool.specs.json`): `web_search(query, count, time_range)`
|
||||
und `fetch_url(url)` gegen `http://searxng:8080` (aiohttp, Browser-UA, 100k-Cap),
|
||||
mit public read `access_grant` für alle User. Für API-Agenten, die per
|
||||
`tool_ids` explizit Tools anfordern (2e).
|
||||
|
||||
## 4. Verifikation (2026-11-12, produktiv auf `10.0.0.90`)
|
||||
|
||||
a) Playbook: `--check --diff` sauber, produktiver Lauf ok, danach **`changed=0`**
|
||||
(Idempotenz, GNAI-010 10.4).
|
||||
b) SearXNG in-container: 168 Ergebnisse in **1,36 s** (vorher: 123 Engines, bis 10 s+).
|
||||
c) Aus dem OpenWebUI-Container via Alias `searxng`: HTTP 200, JSON mit Ergebnissen
|
||||
in **1,9 s**.
|
||||
d) OpenWebUI-Container-Env enthält alle Web-Search-Variablen; Health `HTTP 200`;
|
||||
Model-Row-Meta und `config`-Zeilen korrekt in `webui.db`.
|
||||
e) **E2E-Tool-Loop (Path A, Abschnitt 5)**: Chat via API mit `features.web_search=true`
|
||||
+ `session_id` + `tool_ids=["gnai-web-search"]` — das Modell führte mehrere
|
||||
`web_search`/`fetch_url`-Runden server-seitig aus (sah widersprüchliche Angaben
|
||||
v0.12.5 vs v0.13.0, verifizierte per GitHub-API) und antwortete mit Quellen:
|
||||
„aktuellste Release **v0.13.3** vom 2026-11-08“ — korrekt (Cross-Check gegen
|
||||
`api.github.com/repos/open-webui/open-webui/releases/latest`).
|
||||
f) **E2E nur mit Builtin-Tools** (kein `tool_ids`, nur `session_id` +
|
||||
`features.web_search=true`): Chat-Record zeigt `function_call search_web` ×2 mit
|
||||
echten SearXNG-Ergebnis-JSONs, dann `function_call fetch_url` ×2 mit Seiteninhalt,
|
||||
`sources` enthält die gelesene GitHub-Releases-Seite (Zitation), finale Antwort
|
||||
korrekt mit 3 Quellen. Damit ist der UI-Pfad (neuer Chat, Toggle via
|
||||
`defaultFeatureIds` an) abgedeckt.
|
||||
g) Nach beiden Tests: Playbook-Lauf `changed=0`; Test-Chats gelöscht, temporärer
|
||||
Test-API-Key entfernt, `auth.enable_api_keys` wieder auf `false`.
|
||||
h) **Betreiber-Bestätigung im UI (12.11.2026):** neuer Chat auf frisch geladener
|
||||
Seite — Web-Search-Toggle default an (über `defaultFeatureIds`), das Modell
|
||||
sieht `search_web`/`fetch_url` und nutzt sie im Research-Loop.
|
||||
|
||||
## 5. Betrieb: Websuche in UI und API
|
||||
|
||||
- **UI (Browser, OIDC)**: Web-Search-Toggle im Chat (oder Default-Feature am Modell) →
|
||||
`search_web`/`fetch_url` als Native-Tools; Zitationen erscheinen, sobald das Modell
|
||||
eine Seite per `fetch_url` gelesen hat.
|
||||
- **API-Agenten — Path A (empfohlen, voller agentic Loop server-seitig)**:
|
||||
1. `POST /api/v1/chats/new` (Chat mit User- + leerer Assistant-Message anlegen) → `chat_id`.
|
||||
2. `POST /api/chat/completions` mit `stream:true`, `chat_id`, `id:<assistant-msg-id>`,
|
||||
`session_id:<beliebig non-empty>` (schaltet Builtin-Tools frei), `features:{web_search:true}`,
|
||||
optional `tool_ids:["gnai-web-search"]` → Antwort `{"status":true,"task_ids":[...]}`.
|
||||
3. Ergebnis aus dem Chat lesen: `GET /api/v1/chats/{chat_id}` (Poll bis `done:true`).
|
||||
Ohne `chat_id`+`id`+`stream` werden rohe `tool_calls` an den Client zurückgegeben
|
||||
(Client-seitige Ausführung, OpenAI-Semantik) — siehe docs.openwebui.com
|
||||
„Server-Side Tool Calling (API)".
|
||||
|
||||
Kompakt als curl (API-Key des Users vorausgesetzt; `auth.enable_api_keys` muss
|
||||
global an sein — aktuell `false`, siehe Abschnitt 7):
|
||||
|
||||
```bash
|
||||
# A1: Chat anlegen (User- + leere Assistant-Message)
|
||||
CHAT_ID=$(curl -s -X POST "$OWUI_URL/api/v1/chats/new" -H "Authorization: Bearer $OWUI_KEY" \
|
||||
-H "Content-Type: application/json" -d "{\"chat\":{\"title\":\"run\",\"models\":[\"$MODEL\"],\"history\":{\"currentId\":\"$AID\",\"messages\":{\"$UID\":{\"id\":\"$UID\",\"role\":\"user\",\"content\":\"...\",\"timestamp\":$TS,\"models\":[\"$MODEL\"],\"childrenIds\":[\"$AID\"]},\"$AID\":{\"id\":\"$AID\",\"role\":\"assistant\",\"content\":\"\",\"parentId\":\"$UID\",\"childrenIds\":[],\"model\":\"$MODEL\",\"modelIdx\":0,\"done\":false,\"timestamp\":$((TS+1))}}}}}" | jq -r .id)
|
||||
|
||||
# A2: Completion feuern — server-seitiger Tool-Loop (stream:true + chat_id + id + session_id)
|
||||
curl -s -X POST "$OWUI_URL/api/chat/completions" -H "Authorization: Bearer $OWUI_KEY" \
|
||||
-H "Content-Type: application/json" -d "{\"model\":\"$MODEL\",\"messages\":[{\"role\":\"user\",\"content\":\"Recherchiere ...\"}],\"stream\":true,\"chat_id\":\"$CHAT_ID\",\"id\":\"$AID\",\"session_id\":\"api-$(uuidgen)\",\"features\":{\"web_search\":true}}"
|
||||
# -> {"status":true,"task_ids":[...],"chat_id":"..."}
|
||||
|
||||
# A3: Ergebnis pollen
|
||||
curl -s "$OWUI_URL/api/v1/chats/$CHAT_ID" -H "Authorization: Bearer $OWUI_KEY" | jq ".chat.history.messages[\"$AID\"] | {done, content, sources}"
|
||||
```
|
||||
|
||||
- **Path B** (`params.function_calling:"legacy"` + `tool_ids`): eine Tool-Runde vor
|
||||
der Antwort, Antwort im HTTP-Body — ohne Builtin-Tools.
|
||||
|
||||
## 6. NPM-Proxy-Timeout (CT 103) — erledigt 2026-11-12
|
||||
|
||||
Lange Research-Loops (mehrere Tool-Runden, 128k-Kontext, xhigh) dauern Minuten —
|
||||
der NPM-Default-`proxy_read_timeout` (60 s) schneidet den Stream ab. **Durch den
|
||||
Betreiber am 12.11.2026 ausgeführt:** NPM → Proxy Hosts → `chat.ghostnet.selfhost.eu`
|
||||
→ Edit → Advanced → Custom Nginx: `proxy_read_timeout 600s; proxy_send_timeout 600s;
|
||||
proxy_connect_timeout 60s;` (Websocket-Support war bereits aktiv). Konfiguriert
|
||||
in der NPM-Datenbank auf CT 103, nicht im Repository.
|
||||
|
||||
## 7. Offene Punkte / Erweiterungen
|
||||
|
||||
- `auth.enable_api_keys` steht auf `false` (Default) — API-Keys für Agenten müssen
|
||||
global und pro User freigegeben werden, wenn Agenten Path A nutzen sollen
|
||||
(Betreiber-Entscheidung offen; UI-Verifikation ist auch ohne API-Key möglich).
|
||||
- Optional externer Key (Tavily/Exa/Brave als Podman-Secret + `WEB_SEARCH_ENGINE`),
|
||||
falls SearXNG-Qualität für News nicht reicht (Benchmark: Exa/Tavily ~97–99 %).
|
||||
- Optional MCP: SearXNG-MCP-Container im Egress-Netz als `server:mcp:<id>` in
|
||||
OpenWebUI registrieren (native MCP-Unterstützung seit v0.6.31, Streamable HTTP).
|
||||
- Optional v0.13 „Open Terminal“ (realer Browser/Desktop für das Modell) für
|
||||
JS-lastige Seiten — zusätzlicher Dienst, Egress nötig.
|
||||
- `ENABLE_WEB_SEARCH_CONFIRMATION=True` möglich (User bestätigt jede Suche) — für
|
||||
die interne SearXNG-Instanz nicht gesetzt.
|
||||
- Tool-Loop-Verhalten des Modells bei xhigh/128k überwachen (GPU-Last bei langen
|
||||
Recherchen; ggf. `WEB_SEARCH_RESULT_COUNT` oder `WEB_FETCH_MAX_CONTENT_LENGTH` senken).
|
||||
@@ -14,6 +14,7 @@ Video-Encoding-Workload besitzt einen
|
||||
| [GNAI-008](GNAI-008-PLAN_Ansible-Deployment.md) | nicht finaler Arbeitsentwurf für Ansible- und Gitea-Deployment |
|
||||
| [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 |
|
||||
|
||||
Der übergreifende Projektstand steht im
|
||||
[zentralen Dokumentationsindex](../../../GNAI-000-DOC_Index.md).
|
||||
|
||||
@@ -24,3 +24,22 @@ OpenWebUI zeigt Connection-Modelle Nicht-Admins nur, wenn ein DB-Model-Eintrag
|
||||
existiert UND ein public read access_grant (principal `user`/`*`) greift. Die
|
||||
Rolle stellt beides idempotent sicher (`open_webui_engine_model_id`), daher
|
||||
sehen alle authentifizierten OIDC-User das Modell im Chat-Dropdown.
|
||||
|
||||
## Websuche (GNAI-020, Native/Agentic Mode)
|
||||
|
||||
v0.13.3 nutzt für Websuche die Builtin-Tools `search_web`/`fetch_url`
|
||||
(Native Function Calling ist seit v0.10 Default; `params` des Modell-Eintrags
|
||||
bleibt leer). Gates (utils/tools.py + Chat.svelte): global `ENABLE_WEB_SEARCH=True`
|
||||
(Default in v0.13 ist **False**), Modell-Capability `meta.capabilities.web_search`
|
||||
und `meta.builtinTools.web_search` **sowie** `meta.defaultFeatureIds=["web_search"]`
|
||||
(werden vom Model-Sync-Task idempotent gesetzt — ohne `defaultFeatureIds` startet
|
||||
jeder NEUE Chat mit dem Web-Search-Toggle AUS und das Modell sieht kein
|
||||
`search_web`), pro Request `features.web_search` bzw. Chat-Toggle, User-
|
||||
Permission `features.web_search` (Default true für Rolle `user`). Engine:
|
||||
siehe Rolle `web_search` (SearXNG, kuratierte Engines). `ENABLE_RAG_WEB_SEARCH`
|
||||
wurde entfernt — in v0.13.3 existiert der Legacy-RAG-Pfad nicht mehr, ein
|
||||
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).
|
||||
|
||||
@@ -29,6 +29,10 @@ open_webui_egress_network_name: gnai-production-egress
|
||||
# every authenticated OIDC user sees it (GNAI-005: anwendungsbezogene Rechte).
|
||||
open_webui_engine_model_id: swift-1.5-qwen3.8-27b-q6k
|
||||
|
||||
# Workspace tool (API agents): SearXNG wrapper seeded into the OpenWebUI DB
|
||||
# with a public read grant. API callers pass this id in `tool_ids`.
|
||||
open_webui_web_search_tool_id: gnai-web-search
|
||||
|
||||
# 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).
|
||||
@@ -69,7 +73,24 @@ open_webui_env:
|
||||
DEFAULT_USER_ROLE: user
|
||||
ENABLE_OAUTH_SIGNUP: "False"
|
||||
ENABLE_LOGIN_FORM: "True"
|
||||
ENABLE_RAG_WEB_SEARCH: "True"
|
||||
# Web search (GNAI-020): Native/Agentic Mode (default tool-calling mode
|
||||
# since v0.10) exposes search_web/fetch_url as builtin tools; no RAG, no
|
||||
# embedding model needed. Gates in v0.13.3 (utils/tools.py): global
|
||||
# ENABLE_WEB_SEARCH (default False — without it the tools are never
|
||||
# injected), model capability meta.capabilities.web_search (set by the
|
||||
# model-sync task), per-request features.web_search, user permission
|
||||
# features.web_search (default True for role user). ENABLE_RAG_WEB_SEARCH
|
||||
# existed only in legacy versions and is gone in v0.13.3.
|
||||
ENABLE_WEB_SEARCH: "True"
|
||||
WEB_SEARCH_ENGINE: searxng
|
||||
# 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.
|
||||
SEARXNG_QUERY_URL: http://searxng:8080/search?q=<query>
|
||||
WEB_SEARCH_RESULT_COUNT: "5"
|
||||
WEB_SEARCH_RESULT_COUNT: "8"
|
||||
WEB_SEARCH_CONCURRENT_REQUESTS: "4"
|
||||
# fetch_url reads whole pages into the model context; cap the size.
|
||||
WEB_FETCH_MAX_CONTENT_LENGTH: "100000"
|
||||
# Real browser UA for the web loader / fetch_url (bot detection of large
|
||||
# publishers otherwise answers 403/empty).
|
||||
USER_AGENT: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import html
|
||||
import json
|
||||
import re
|
||||
|
||||
import aiohttp
|
||||
|
||||
|
||||
class Tools:
|
||||
"""Web search + page fetch via the self-hosted SearXNG metasearch.
|
||||
|
||||
SearXNG runs in the same egress network as OpenWebUI (alias `searxng`,
|
||||
no external API key). UI chats get the builtin search_web/fetch_url
|
||||
tools; API callers must pass this tool's id in `tool_ids` (OpenWebUI
|
||||
v0.13 does not inject builtin tools for API requests).
|
||||
"""
|
||||
|
||||
SEARXNG_URL: str = "http://searxng:8080/search"
|
||||
USER_AGENT: str = (
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 "
|
||||
"(KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
|
||||
)
|
||||
MAX_CONTENT_LENGTH: int = 100000 # mirrors WEB_FETCH_MAX_CONTENT_LENGTH
|
||||
|
||||
async def web_search(self, query: str, count: int = 8, time_range: str = "") -> str:
|
||||
"""
|
||||
Search the web via the self-hosted SearXNG metasearch engine.
|
||||
:param query: The search query (natural language works).
|
||||
:param count: Maximum number of results (1-20, default 8).
|
||||
:param time_range: Freshness filter: "day", "week", "month", "year" or "" for any time.
|
||||
:return: JSON string with "query" and "results" (array of url/title/snippet).
|
||||
"""
|
||||
try:
|
||||
count = max(1, min(int(count or 8), 20))
|
||||
except (TypeError, ValueError):
|
||||
count = 8
|
||||
params = {"q": query, "format": "json", "safesearch": "1", "language": "all"}
|
||||
if time_range in ("day", "week", "month", "year"):
|
||||
params["time_range"] = time_range
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(
|
||||
self.SEARXNG_URL,
|
||||
params=params,
|
||||
headers={"User-Agent": self.USER_AGENT, "Accept": "application/json"},
|
||||
timeout=aiohttp.ClientTimeout(total=30),
|
||||
) as resp:
|
||||
resp.raise_for_status()
|
||||
data = await resp.json(content_type=None)
|
||||
results = [
|
||||
{
|
||||
"url": r.get("url", ""),
|
||||
"title": r.get("title", ""),
|
||||
"snippet": r.get("content", ""),
|
||||
}
|
||||
for r in data.get("results", [])
|
||||
][:count]
|
||||
return json.dumps({"query": query, "results": results}, ensure_ascii=False)
|
||||
|
||||
async def fetch_url(self, url: str) -> str:
|
||||
"""
|
||||
Fetch one URL and return its text content (HTML tags stripped), truncated.
|
||||
:param url: The http(s) URL to fetch.
|
||||
:return: The page text (max 100000 characters), or an error string.
|
||||
"""
|
||||
if not url.startswith(("http://", "https://")):
|
||||
return f"error: not an http(s) URL: {url!r}"
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(
|
||||
url,
|
||||
headers={"User-Agent": self.USER_AGENT, "Accept": "text/html,*/*"},
|
||||
timeout=aiohttp.ClientTimeout(total=30),
|
||||
) as resp:
|
||||
if resp.status != 200:
|
||||
return f"error: HTTP {resp.status} for {url}"
|
||||
raw = await resp.content.read(1_000_000)
|
||||
text = raw.decode("utf-8", errors="replace")
|
||||
text = re.sub(r"(?is)<(script|style|noscript).*?</\1>", " ", text)
|
||||
text = re.sub(r"(?s)<[^>]+>", " ", text)
|
||||
text = html.unescape(text)
|
||||
text = re.sub(r"[ \t]+", " ", text)
|
||||
text = re.sub(r"\n\s*\n+", "\n\n", text).strip()
|
||||
if len(text) > self.MAX_CONTENT_LENGTH:
|
||||
text = text[: self.MAX_CONTENT_LENGTH] + "\n[Content truncated...]"
|
||||
return text or "error: empty content"
|
||||
except Exception as e:
|
||||
return f"error: {type(e).__name__}: {e}"
|
||||
@@ -0,0 +1,41 @@
|
||||
[
|
||||
{
|
||||
"name": "web_search",
|
||||
"description": "Search the web via the self-hosted SearXNG metasearch engine.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"query": {
|
||||
"type": "string",
|
||||
"description": "The search query (natural language works)."
|
||||
},
|
||||
"count": {
|
||||
"type": "integer",
|
||||
"description": "Maximum number of results (1-20, default 8).",
|
||||
"default": 8
|
||||
},
|
||||
"time_range": {
|
||||
"type": "string",
|
||||
"enum": ["", "day", "week", "month", "year"],
|
||||
"description": "Freshness filter; empty string means any time.",
|
||||
"default": ""
|
||||
}
|
||||
},
|
||||
"required": ["query"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "fetch_url",
|
||||
"description": "Fetch one URL and return its text content (HTML tags stripped), truncated to 100000 characters.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"url": {
|
||||
"type": "string",
|
||||
"description": "The http(s) URL to fetch."
|
||||
}
|
||||
},
|
||||
"required": ["url"]
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -233,24 +233,53 @@
|
||||
- not ansible_check_mode
|
||||
- open_webui_unit_state.rc != 0
|
||||
|
||||
- name: Ensure the engine model is synced and publicly readable in OpenWebUI
|
||||
- name: Ensure the engine model is synced, web-search capable and publicly readable in OpenWebUI
|
||||
# OpenWebUI shows connection models to non-admin users only when a DB model
|
||||
# row exists and a public read access_grant covers it (v0.13 access control).
|
||||
# Idempotent; touches only the app DB, no secrets.
|
||||
# The row's meta also gets capabilities.web_search + builtinTools.web_search
|
||||
# = true and defaultFeatureIds=["web_search"]: in v0.13.3 the builtin tools
|
||||
# search_web/fetch_url are injected only when the capability and builtinTools
|
||||
# category are set (utils/tools.py get_builtin_tools; they default to true,
|
||||
# but setting them explicitly keeps API agents working even after a UI
|
||||
# toggle), and a NEW chat starts with the web-search toggle ON only when
|
||||
# defaultFeatureIds contains "web_search" (Chat.svelte defaultFeature()).
|
||||
# Native function calling is the default tool-calling mode since v0.10, so
|
||||
# params stay empty. Idempotent; touches only the app DB, no secrets.
|
||||
ansible.builtin.shell: |
|
||||
set -euo pipefail
|
||||
python3 - "{{ open_webui_data_dir }}/webui.db" "{{ open_webui_engine_model_id }}" <<'PYEOF'
|
||||
import sqlite3, sys, time, uuid
|
||||
import json, sqlite3, sys, time, uuid
|
||||
db, model_id = sys.argv[1], sys.argv[2]
|
||||
con = sqlite3.connect(db)
|
||||
now = int(time.time())
|
||||
row = con.execute("select id from model where id=?", (model_id,)).fetchone()
|
||||
changed = False
|
||||
row = con.execute("select id, meta from model where id=?", (model_id,)).fetchone()
|
||||
if not row:
|
||||
con.execute(
|
||||
"insert into model (id, user_id, base_model_id, name, params, meta, is_active, version_id, created_at, updated_at)"
|
||||
" values (?,?,?,?,?,?,?,?,?,?)",
|
||||
(model_id, "openwebui", None, model_id, "{}", "{}", 1, str(uuid.uuid4()), now, now),
|
||||
)
|
||||
changed = True
|
||||
meta = {}
|
||||
else:
|
||||
meta = json.loads(row[1] or "{}")
|
||||
caps = meta.get("capabilities") or {}
|
||||
builtin = meta.get("builtinTools") or {}
|
||||
meta["capabilities"] = caps
|
||||
meta["builtinTools"] = builtin
|
||||
df = meta.get("defaultFeatureIds") or []
|
||||
if (
|
||||
caps.get("web_search") is not True
|
||||
or builtin.get("web_search") is not True
|
||||
or "web_search" not in df
|
||||
):
|
||||
caps["web_search"] = True
|
||||
builtin["web_search"] = True
|
||||
if "web_search" not in df:
|
||||
meta["defaultFeatureIds"] = [*df, "web_search"]
|
||||
con.execute("update model set meta=?, updated_at=? where id=?", (json.dumps(meta), now, model_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'",
|
||||
(model_id,),
|
||||
@@ -261,8 +290,9 @@
|
||||
" values (?,?,?,?,?,?,?)",
|
||||
(str(uuid.uuid4()), "model", model_id, "user", "*", "read", now),
|
||||
)
|
||||
changed = True
|
||||
con.commit()
|
||||
print("CHANGED" if (not row or not grant) else "UNCHANGED")
|
||||
print("CHANGED" if changed else "UNCHANGED")
|
||||
PYEOF
|
||||
args:
|
||||
executable: /bin/bash
|
||||
@@ -270,6 +300,126 @@
|
||||
register: open_webui_model_sync
|
||||
changed_when: open_webui_model_sync.stdout_lines | first == 'CHANGED'
|
||||
|
||||
- name: Ensure the persisted web-search config matches the env (in v0.13 the DB config wins over env)
|
||||
# OpenWebUI persists every ConfigVar in the `config` table and a saved value
|
||||
# takes precedence over the environment variable ("the variable seeds the
|
||||
# initial value, and the saved setting wins afterwards"). The env block
|
||||
# seeds the container; this task aligns the DB rows so a stale value saved
|
||||
# from the admin UI cannot silently disable web search. Config is read per
|
||||
# request, no restart needed. Idempotent; touches only the app DB.
|
||||
ansible.builtin.shell: |
|
||||
set -euo pipefail
|
||||
python3 - "{{ open_webui_data_dir }}/webui.db" '{{ open_webui_web_config | to_json }}' <<'PYEOF'
|
||||
import json, sqlite3, sys, time
|
||||
db, wanted_raw = sys.argv[1], sys.argv[2]
|
||||
wanted = json.loads(wanted_raw)
|
||||
now = int(time.time())
|
||||
con = sqlite3.connect(db)
|
||||
changed = False
|
||||
for key, value in wanted.items():
|
||||
row = con.execute("select value from config where key=?", (key,)).fetchone()
|
||||
# the JSON column has NUMERIC affinity: numeric values come back as int
|
||||
raw = row[0] if row else None
|
||||
current = json.loads(raw) if isinstance(raw, str) else raw
|
||||
if current != value:
|
||||
con.execute(
|
||||
"insert or replace into config (key, value, updated_at) values (?,?,?)",
|
||||
(key, json.dumps(value), now),
|
||||
)
|
||||
changed = True
|
||||
con.commit()
|
||||
print("CHANGED" if changed else "UNCHANGED")
|
||||
PYEOF
|
||||
args:
|
||||
executable: /bin/bash
|
||||
vars:
|
||||
open_webui_web_config:
|
||||
web.search.enable: "{{ open_webui_env.ENABLE_WEB_SEARCH | lower == 'true' }}"
|
||||
web.search.engine: "{{ open_webui_env.WEB_SEARCH_ENGINE }}"
|
||||
web.search.searxng_query_url: "{{ open_webui_env.SEARXNG_QUERY_URL }}"
|
||||
web.search.result_count: "{{ open_webui_env.WEB_SEARCH_RESULT_COUNT | int }}"
|
||||
web.search.concurrent_requests: "{{ open_webui_env.WEB_SEARCH_CONCURRENT_REQUESTS | int }}"
|
||||
web.fetch.max_content_length: "{{ open_webui_env.WEB_FETCH_MAX_CONTENT_LENGTH | int }}"
|
||||
when: not ansible_check_mode
|
||||
register: open_webui_web_config_sync
|
||||
changed_when: open_webui_web_config_sync.stdout_lines | first == 'CHANGED'
|
||||
|
||||
- name: Stage the web-search tool sources on the host
|
||||
ansible.builtin.copy:
|
||||
src: "files/{{ item }}"
|
||||
dest: "/tmp/{{ item }}"
|
||||
mode: "0600"
|
||||
loop:
|
||||
- gnai-web-search-tool.py
|
||||
- gnai-web-search-tool.specs.json
|
||||
# The DB sync task below reports the real change; staging is plumbing.
|
||||
changed_when: false
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Ensure the API-agent web-search tool exists in OpenWebUI (SearXNG wrapper)
|
||||
# In v0.13 the builtin tools (search_web/fetch_url) are only injected for
|
||||
# UI-originated requests (session_id present); API callers must pass a
|
||||
# workspace tool via `tool_ids` in the request body. This seeds one
|
||||
# idempotently from role files (content + specs), with a public read grant.
|
||||
# Idempotent; touches only the app DB, no secrets.
|
||||
ansible.builtin.shell: |
|
||||
set -euo pipefail
|
||||
python3 - "{{ open_webui_data_dir }}/webui.db" \
|
||||
/tmp/gnai-web-search-tool.py \
|
||||
/tmp/gnai-web-search-tool.specs.json \
|
||||
"{{ open_webui_web_search_tool_id }}" <<'PYEOF'
|
||||
import json, sqlite3, sys, time, uuid
|
||||
db, content_path, specs_path, tool_id = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]
|
||||
content = open(content_path).read()
|
||||
specs = open(specs_path).read()
|
||||
meta = json.dumps({"description": "Self-hosted SearXNG web search + URL fetch for API agents (GNAI-020). API callers: pass this tool id in tool_ids."})
|
||||
now = int(time.time())
|
||||
con = sqlite3.connect(db)
|
||||
changed = False
|
||||
row = con.execute("select content, specs, meta, is_active from tool where id=?", (tool_id,)).fetchone()
|
||||
if not row:
|
||||
con.execute(
|
||||
"insert into tool (id, user_id, name, content, specs, meta, valves, updated_at, created_at, version_id, is_active)"
|
||||
" values (?,?,?,?,?,?,?,?,?,?,?)",
|
||||
(tool_id, "openwebui", "gnai-web-search", content, specs, meta, "{}", now, now, str(uuid.uuid4()), 1),
|
||||
)
|
||||
changed = True
|
||||
elif row[0] != content or row[1] != specs or row[2] != meta or row[3] != 1:
|
||||
con.execute(
|
||||
"update tool set content=?, specs=?, meta=?, is_active=1, updated_at=?, version_id=? where id=?",
|
||||
(content, specs, meta, now, str(uuid.uuid4()), tool_id),
|
||||
)
|
||||
changed = True
|
||||
grant = con.execute(
|
||||
"select id from access_grant where resource_type='tool' and resource_id=? and principal_type='user' and principal_id='*' and permission='read'",
|
||||
(tool_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()), "tool", tool_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_tool_sync
|
||||
changed_when: open_webui_tool_sync.stdout_lines | first == 'CHANGED'
|
||||
|
||||
- name: Remove the staged tool sources
|
||||
ansible.builtin.file:
|
||||
path: "/tmp/{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- gnai-web-search-tool.py
|
||||
- gnai-web-search-tool.specs.json
|
||||
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"
|
||||
|
||||
@@ -15,17 +15,17 @@ Volume={{ open_webui_data_dir }}:/app/backend/data:rw
|
||||
Secret={{ open_webui_webui_secret_key_secret }},type=env,target=WEBUI_SECRET_KEY
|
||||
Secret={{ open_webui_engine_api_key_secret }},type=env,target=OPENAI_API_KEY
|
||||
{% for key, value in open_webui_env.items() %}
|
||||
Environment={{ key }}={{ value }}
|
||||
Environment="{{ key }}={{ value }}"
|
||||
{% endfor %}
|
||||
{% if open_webui_oidc_enabled %}
|
||||
Environment=WEBUI_URL={{ open_webui_public_url }}
|
||||
Environment=ENABLE_OAUTH_SIGNUP=True
|
||||
Environment=ENABLE_SIGNUP=False
|
||||
Environment=OPENID_PROVIDER_URL={{ open_webui_oidc_provider_url }}
|
||||
Environment=OAUTH_CLIENT_ID={{ open_webui_oidc_client_id }}
|
||||
Environment=OAUTH_SCOPES=openid email profile
|
||||
Environment=OAUTH_CODE_CHALLENGE_METHOD=S256
|
||||
Environment=OAUTH_PROVIDER_NAME=Keycloak
|
||||
Environment="WEBUI_URL={{ open_webui_public_url }}"
|
||||
Environment="ENABLE_OAUTH_SIGNUP=True"
|
||||
Environment="ENABLE_SIGNUP=False"
|
||||
Environment="OPENID_PROVIDER_URL={{ open_webui_oidc_provider_url }}"
|
||||
Environment="OAUTH_CLIENT_ID={{ open_webui_oidc_client_id }}"
|
||||
Environment="OAUTH_SCOPES=openid email profile"
|
||||
Environment="OAUTH_CODE_CHALLENGE_METHOD=S256"
|
||||
Environment="OAUTH_PROVIDER_NAME=Keycloak"
|
||||
{% if open_webui_oidc_use_client_secret %}Secret={{ open_webui_oidc_client_secret_secret }},type=env,target=OAUTH_CLIENT_SECRET
|
||||
{% endif %}{% endif %}
|
||||
|
||||
|
||||
@@ -6,12 +6,25 @@ mit Netzwerk-Alias `searxng` im Egress-Netz `gnai-production-egress`
|
||||
(kein Host-Port, kein Ingress von außen). Secret-Key als Podman-Secret
|
||||
(`SEARXNG_SECRET` env), Settings ohne Secret auf der Platte.
|
||||
|
||||
OpenWebUI-seitig (Rolle `open_webui`): `WEB_SEARCH_ENGINE=searxng`,
|
||||
`SEARXNG_QUERY_URL=http://searxng:8080/search?q=<query>`,
|
||||
`ENABLE_RAG_WEB_SEARCH=True`, `WEB_SEARCH_RESULT_COUNT=5`.
|
||||
OpenWebUI-seitig (Rolle `open_webui`): `ENABLE_WEB_SEARCH=True` (in v0.13
|
||||
Default **False** — ohne dieses Gate werden `search_web`/`fetch_url` nie
|
||||
injiziert), `WEB_SEARCH_ENGINE=searxng`,
|
||||
`SEARXNG_QUERY_URL=http://searxng:8080/search?q=<query>` (v0.13.3 streicht
|
||||
den Query-String und setzt `q`/`format=json` selbst), plus Native/Agentic
|
||||
Mode (Default seit v0.10) mit Modell-Capability `web_search`.
|
||||
|
||||
## Kuratierte Engines + Timeouts (GNAI-020)
|
||||
|
||||
`use_default_settings` bleibt aktiv, aber `engines.keep_only` lädt nur die
|
||||
in `web_search_engines` (defaults) gelisteten ~45 Engines (Web, News, Wikis,
|
||||
IT/Doku, Science/Security) statt der 123 Default-Engines. Jedes Engine wird
|
||||
per `engines:`-Override auf `disabled: false` und `categories: [general]`
|
||||
gesetzt — OpenWebUI sendet keinen `categories`-Parameter, SearXNG würde sonst
|
||||
nur die Kategorie `general` durchsuchen. `outgoing.request_timeout: 2.5s`,
|
||||
`max_request_timeout: 8s` begrenzen die Gesamtlatenz; `suspended_times` ist
|
||||
auf Minuten verkürzt (Datacenter-Egress-IPs landen sonst tagelang auf
|
||||
CAPTCHA/429-Bans).
|
||||
|
||||
Verifiziert 11.11.2026: SearXNG antwortet im Netz (39 Ergebnisse für
|
||||
Testquery), aus dem OpenWebUI-Container via Alias erreichbar. Offen: der
|
||||
Chat-Request mit `features.web_search=true` hängt im Tool-Flow des Modells
|
||||
(kein Generieren, llama idle) — NPM-Proxy-Timeout für chat.* muss sowieso
|
||||
erhöht werden; Tool-Loop-Verhalten des Modells bei xhigh/128k prüfen.
|
||||
Testquery), aus dem OpenWebUI-Container via Alias erreichbar. Der Playbook-
|
||||
Probe prüft inzwischen, dass die JSON-API tatsächlich Ergebnisse liefert.
|
||||
|
||||
@@ -20,3 +20,65 @@ web_search_container_port: 8080
|
||||
# git; it is generated as a Podman secret on first run.
|
||||
web_search_config_dir: /etc/searxng-ghostnet
|
||||
web_search_secret_key_secret: searxng-secret-key
|
||||
|
||||
# Curated engine set, names exactly as in searxng's default settings.yml of
|
||||
# the pinned image (2026.11.11-626105eec, commit 626105eec). The default
|
||||
# settings enable 123 engines (incl. key-less API engines and adult/warez
|
||||
# indexes) — slow and noisy for an agent backend. `keep_only` restricts the
|
||||
# loaded set to this list; the template additionally forces every engine
|
||||
# into the "general" category, because OpenWebUI queries SearXNG without a
|
||||
# `categories` parameter and SearXNG then searches "general" only.
|
||||
web_search_engines:
|
||||
# general web
|
||||
- bing
|
||||
- brave
|
||||
- duckduckgo
|
||||
- startpage
|
||||
- mojeek
|
||||
- qwant
|
||||
- swisscows
|
||||
- mwmbl
|
||||
- marginalia
|
||||
# news
|
||||
- bing news
|
||||
- brave.news
|
||||
- duckduckgo news
|
||||
- mojeek news
|
||||
- startpage news
|
||||
- swisscows news
|
||||
- yahoo news
|
||||
- reuters
|
||||
- tagesschau
|
||||
# wikis / reference
|
||||
- wikipedia
|
||||
- wikidata
|
||||
# IT / dev / docs
|
||||
- github
|
||||
- github code
|
||||
- gitlab
|
||||
- stackoverflow
|
||||
- askubuntu
|
||||
- superuser
|
||||
- arch linux wiki
|
||||
- pypi
|
||||
- npm
|
||||
- crates.io
|
||||
- repology
|
||||
- docker hub
|
||||
- microsoft learn
|
||||
- mdn
|
||||
- hackernews
|
||||
# science / security
|
||||
- arxiv
|
||||
- semantic scholar
|
||||
- pubmed
|
||||
- europepmc
|
||||
- openalex
|
||||
- crossref
|
||||
- springer nature
|
||||
- national vulnerability database
|
||||
|
||||
# Upstream timeouts bound the total search time: the JSON API waits for all
|
||||
# engines to answer or hit their individual timeout.
|
||||
web_search_request_timeout: 2.5
|
||||
web_search_max_request_timeout: 8
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
- not ansible_check_mode
|
||||
- web_search_unit_state.rc != 0
|
||||
|
||||
- name: Wait for SearXNG to answer inside the egress network
|
||||
- name: Wait for SearXNG to return real results (JSON API) inside the egress network
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- /usr/sbin/runuser
|
||||
@@ -178,7 +178,7 @@
|
||||
- "{{ web_search_unit_prefix }}"
|
||||
- /usr/bin/python3
|
||||
- -c
|
||||
- "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/search?q=test&format=json', timeout=10)"
|
||||
- "import json, urllib.request; p = json.load(urllib.request.urlopen('http://127.0.0.1:8080/search?q=openwebui&format=json', timeout=15)); assert p.get('results'), 'no results from curated engines'"
|
||||
chdir: "{{ web_search_home }}"
|
||||
register: web_search_probe
|
||||
retries: 20
|
||||
|
||||
@@ -1,11 +1,48 @@
|
||||
use_default_settings: true
|
||||
# SearXNG for the OpenWebUI web-search backend (JSON API), curated engine set.
|
||||
# secret_key comes from env SEARXNG_SECRET (Podman secret), never on disk.
|
||||
#
|
||||
# `keep_only` restricts the loaded engines to web_search_engines (see role
|
||||
# defaults); the ~123 default engines (incl. key-less API engines, image/
|
||||
# warez indexes) stay unloaded. Every kept engine is forced into the
|
||||
# "general" category and explicitly enabled, because OpenWebUI queries
|
||||
# without a `categories` parameter (SearXNG then searches "general" only)
|
||||
# and several engines ship `disabled: true` in the default settings.
|
||||
use_default_settings:
|
||||
engines:
|
||||
keep_only:
|
||||
{% for engine in web_search_engines %}
|
||||
- "{{ engine }}"
|
||||
{% endfor %}
|
||||
|
||||
server:
|
||||
# secret_key comes from env SEARXNG_SECRET (Podman secret), never on disk
|
||||
limiter: false
|
||||
image_proxy: false
|
||||
bind_address: 0.0.0.0
|
||||
port: {{ web_search_container_port }}
|
||||
|
||||
search:
|
||||
formats:
|
||||
- html
|
||||
- json
|
||||
default_lang: auto
|
||||
# Recover quickly from upstream 403/429/CAPTCHA bans (typical for
|
||||
# datacenter egress IPs) instead of the multi-day defaults.
|
||||
suspended_times:
|
||||
SearxEngineAccessDenied: 60
|
||||
SearxEngineCaptcha: 300
|
||||
SearxEngineTooManyRequests: 60
|
||||
cf_SearxEngineCaptcha: 600
|
||||
cf_SearxEngineAccessDenied: 300
|
||||
recaptcha_SearxEngineCaptcha: 600
|
||||
|
||||
outgoing:
|
||||
request_timeout: {{ web_search_request_timeout }}
|
||||
max_request_timeout: {{ web_search_max_request_timeout }}
|
||||
|
||||
engines:
|
||||
{% for engine in web_search_engines %}
|
||||
- name: "{{ engine }}"
|
||||
disabled: false
|
||||
categories:
|
||||
- general
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user