fix: combine specialist tools with native web search

This commit is contained in:
Mikei386
2026-08-24 12:25:12 +02:00
parent 5834342f8c
commit 5528f3ab22
4 changed files with 71 additions and 13 deletions
@@ -1,7 +1,7 @@
"""
title: MikeAI Auto Tool Selector
author: MikeAI
version: 3.4.0
version: 3.5.0
description: Selects a small, relevant set of MCP servers for each user request.
"""
@@ -74,6 +74,19 @@ class Filter:
return str(content)
return ""
def _needs_native_web(self, raw_text: str) -> bool:
"""Return whether this request explicitly requires current public-web evidence."""
text = self._normalise(raw_text)
return self._matches(
text,
(
r"\b(?:web|internet|online|websuche|webrecherche)\b",
r"\b(?:such|recherchier|pr[uü]f|schau)\w*\b.{0,80}\b(?:netz|web|internet|online)\b",
r"\b(?:deezer|youtube|makerworld|wikipedia|docker\s*hub)\b",
r"\b(?:aktuell|neueste|heute|bis heute)\w*\b.{0,100}\b(?:quelle|liste|verf[uü]gbar|erschienen|video|folge)\w*\b",
),
)
@staticmethod
def _add_system_rule(body: dict, labels: list[str], selected: list[str]) -> None:
rule = (
@@ -277,8 +290,25 @@ class Filter:
if not self.valves.enabled:
return body
selected = self._classify(self._latest_user_text(body))
latest_text = self._latest_user_text(body)
selected = self._classify(latest_text)
needs_native_web = self._needs_native_web(latest_text)
if not selected and not needs_native_web:
return body
if needs_native_web:
features = body.setdefault("features", {})
if isinstance(features, dict):
features["web_search"] = True
metadata = body.setdefault("metadata", {})
if isinstance(metadata, dict):
metadata_features = metadata.setdefault("features", {})
if isinstance(metadata_features, dict):
metadata_features["web_search"] = True
if not selected:
if needs_native_web:
await self._notify(__event_emitter__, ["native Websuche"])
return body
existing = body.get("tool_ids")
@@ -298,7 +328,7 @@ class Filter:
# never overwritten.
if (
self.valves.enable_multidomain_reasoning
and len(selected) >= 2
and len(selected) + int(needs_native_web) >= 2
and body.get("reasoning_effort") in (None, "", "none")
):
body["reasoning_effort"] = self.valves.multidomain_reasoning_effort
@@ -306,6 +336,19 @@ class Filter:
body["reasoning_budget"] = self.valves.multidomain_reasoning_budget
labels = [self.LABELS[category] for category in selected]
self._add_system_rule(body, labels, selected)
if needs_native_web:
labels.append("native Websuche")
if selected:
self._add_system_rule(body, labels, selected)
if needs_native_web:
for message in body.get("messages", []):
if message.get("role") == "system" and isinstance(message.get("content"), str):
message["content"] += (
" Native Open WebUI web search is also enabled for this request. "
"After collecting local or specialist-tool evidence, continue with "
"search_web/fetch_url for current public evidence; do not stop merely "
"because no separate web MCP appears in the MCP tool list."
)
break
await self._notify(__event_emitter__, labels)
return body