Improve MCP tool selection guidance
This commit is contained in:
@@ -134,10 +134,94 @@ with con:
|
||||
""",
|
||||
(key, json.dumps(value), now),
|
||||
)
|
||||
|
||||
# Improve model-side tool selection without touching URLs, credentials,
|
||||
# access grants or enable flags from a restored Open WebUI database.
|
||||
row = con.execute(
|
||||
"select value from config where key=?",
|
||||
("tool_server.connections",),
|
||||
).fetchone()
|
||||
if row:
|
||||
connections = json.loads(row[0])
|
||||
if not isinstance(connections, list):
|
||||
raise SystemExit("Unbekanntes Format in tool_server.connections.")
|
||||
descriptions = {
|
||||
"web-local": (
|
||||
"Web (öffentlich, read-only)",
|
||||
"Für aktuelle öffentliche Internetdaten, Quellenprüfung, GitHub/Hugging Face "
|
||||
"und Produktsuche. Nicht für Home Assistant, Medienverwaltung oder NAS-Diagnose.",
|
||||
),
|
||||
"homeassistant-local": (
|
||||
"Home Assistant (lokal)",
|
||||
"Nur für Home-Assistant-Entitäten, Zustände, Historie, Automationen, Dashboards "
|
||||
"und HA-Diagnose. Nicht für Unraid, Sonarr/Radarr oder allgemeine Websuche.",
|
||||
),
|
||||
"arr-local": (
|
||||
"Sonarr und Radarr (lokal)",
|
||||
"Nur für verwaltete Serien/Filme, fehlende Episoden, Queue und Suche über "
|
||||
"konfigurierte Indexer. Keine allgemeine Websuche; Schreibaktionen benötigen "
|
||||
"Vorschau und Freigabe.",
|
||||
),
|
||||
"unraid-readonly-local": (
|
||||
"Unraid (Systemdiagnose)",
|
||||
"Bevorzugtes Werkzeug für lesende Unraid-Diagnose: Host, Array, Datenträger, "
|
||||
"Docker, Shares, Netzwerk, UPS und Logs. Für dieselbe Anfrage nicht zusätzlich "
|
||||
"MUA aufrufen; MUA nur für dessen spezielle oder freigegebene Verwaltungsaktionen.",
|
||||
),
|
||||
"mua": (
|
||||
"MUA (Unraid-Verwaltung)",
|
||||
"Nur für ausdrücklich benötigte MUA-spezifische oder freigegebene Unraid-"
|
||||
"Verwaltungsaktionen. Für reine Statusabfragen und Diagnosen stattdessen "
|
||||
"Unraid (Systemdiagnose) verwenden; niemals beide parallel ausprobieren.",
|
||||
),
|
||||
}
|
||||
changed = False
|
||||
for connection in connections:
|
||||
if not isinstance(connection, dict):
|
||||
continue
|
||||
info = connection.get("info")
|
||||
if not isinstance(info, dict):
|
||||
info = {}
|
||||
connection["info"] = info
|
||||
identity = str(info.get("id", "")).lower()
|
||||
url = str(connection.get("url", "")).lower()
|
||||
if identity in descriptions:
|
||||
match = identity
|
||||
elif "192.168.1.2:3002" in url:
|
||||
match = "mua"
|
||||
elif "mike-ai-mcp-web" in url:
|
||||
match = "web-local"
|
||||
elif "mike-ai-mcp-homeassistant" in url:
|
||||
match = "homeassistant-local"
|
||||
elif "mike-ai-mcp-arr" in url:
|
||||
match = "arr-local"
|
||||
elif "mike-ai-mcp-unraid-official" in url:
|
||||
match = "unraid-readonly-local"
|
||||
else:
|
||||
continue
|
||||
name, description = descriptions[match]
|
||||
if info.get("name") != name or info.get("description") != description:
|
||||
info["name"] = name
|
||||
info["description"] = description
|
||||
changed = True
|
||||
if changed:
|
||||
con.execute(
|
||||
"""
|
||||
insert into config (key,value,updated_at) values (?,?,?)
|
||||
on conflict(key) do update set
|
||||
value=excluded.value,
|
||||
updated_at=excluded.updated_at
|
||||
""",
|
||||
(
|
||||
"tool_server.connections",
|
||||
json.dumps(connections, ensure_ascii=False),
|
||||
now,
|
||||
),
|
||||
)
|
||||
print(
|
||||
"OpenWebUI konfiguriert: Default Off=10, Thinking=20, "
|
||||
"Stability Guard=30, Secret Redaction=40, Local Metrics=90, "
|
||||
"Quick Actions=100, Folgefragen=aus, Piper-TTS=aktiv"
|
||||
"Quick Actions=100, Folgefragen=aus, Piper-TTS=aktiv, Werkzeugwahl=optimiert"
|
||||
)
|
||||
PY
|
||||
|
||||
|
||||
Reference in New Issue
Block a user