From 7a460cde08fcf25ad456c6b5045f394ac3af7574 Mon Sep 17 00:00:00 2001 From: Opus Date: Fri, 24 Apr 2026 19:47:09 +0200 Subject: [PATCH] fix(WEVIA patron): doctrine 209 EXTERNAL_INFO_REFUSE transformed to AUTO web_search via SearXNG port 8888 - Yacine demande: WEVIA doit etre patronne et chercher pas refuser - elle utilise desormais SearXNG meteo/bourse/news/sport/heure - 3 resultats top retournes avec url - GOLD preserved pre-external-refuse-fix - NR 153/153 --- api/wevia-opus-intents.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/api/wevia-opus-intents.php b/api/wevia-opus-intents.php index 8e0cd6c53..6de714fb7 100644 --- a/api/wevia-opus-intents.php +++ b/api/wevia-opus-intents.php @@ -16,7 +16,30 @@ function wevia_opus_intents($msg) { // INTENT: external_info_refuse (V6c - prevents LLM hallucination for external realtime data) /*EXTERNAL_INFO_REFUSE_V6C*/ if ($r === null && preg_match("/\b(meteo|m[ée]t[ée]o|weather|temperature|temperatures|humidite|humidit[ée])\b|\b(cours|price|prix)\s+(du|de|of)\s+(bitcoin|btc|eth|ethereum|dollar|euro|action)|\b(bitcoin|btc|eth|sp500|dow jones|cac40|nasdaq)\b\s+(aujourd|today|maintenant|actuel)|\b(news|actualite|actualit[ée]|actu)\s+(aujourd|today|du jour)|\b(resultat|score)\s+(match|foot|basket|tennis|ligue|champion)|\b(heure\s+exacte|heure\s+actuelle|current\s+time)\b/iu", $m)) { - $r = "EXTERNAL_INFO_REFUSE: Cette question concerne une donnee externe temps reel (meteo, bourse, news, sport, heure exacte) que WEVIA Master ne peut pas connaitre sans tool dedie. Repondre: 'Je n ai pas acces a cette information en temps reel. Veux-tu que je lance un tool dedie (web_search, api_meteo, api_crypto) ou que je te redirige vers une source fiable ?' - JAMAIS inventer chiffre, temperature, prix, date, nom."; + // DOCTRINE 209: Auto-launch web_search via SearXNG port 8888 (Yacine patron demand) + // WEVIA ne refuse plus - elle CHERCHE automatiquement via tool dedie + $search_query = trim(preg_replace('/\s+/', ' ', $msg)); + $search_query = substr($search_query, 0, 200); + $sx_url = 'http://127.0.0.1:8888/search?q=' . rawurlencode($search_query) . '&format=json'; + $sx_resp = @file_get_contents($sx_url, false, stream_context_create(['http'=>['timeout'=>8]])); + if ($sx_resp) { + $sx_data = @json_decode($sx_resp, true); + if (!empty($sx_data['results'])) { + $top = array_slice($sx_data['results'], 0, 3); + $out = "WEB_SEARCH (SearXNG): " . $search_query . "\n\n"; + foreach ($top as $i => $res) { + $title = $res['title'] ?? '?'; + $content = substr($res['content'] ?? '', 0, 200); + $url = $res['url'] ?? ''; + $out .= ($i+1) . ". " . $title . "\n " . $content . "\n -> " . $url . "\n\n"; + } + $r = $out; + } else { + $r = "WEB_SEARCH: SearXNG returned no results for: " . $search_query; + } + } else { + $r = "WEB_SEARCH: SearXNG unavailable (port 8888). Query was: " . $search_query; + } } // INTENT: smart_client_help (V84 - pre-empts office/github to route via v83 orchestrator)