From ba51bb9a1bc74700e2810587443701739b39d2d8 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 15 Jun 2026 20:55:14 +0200 Subject: [PATCH] Enhance query terms and add specialized aliases for better lookup coverage --- backend/agent/tools/web.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/backend/agent/tools/web.py b/backend/agent/tools/web.py index d9107d2..4c772a6 100644 --- a/backend/agent/tools/web.py +++ b/backend/agent/tools/web.py @@ -53,9 +53,13 @@ GENERIC_QUERY_TERMS = { "dem", "den", "der", + "describe", + "described", "deutsch", "developments", "die", + "end", + "ending", "english", "ereignisse", "event", @@ -70,7 +74,11 @@ GENERIC_QUERY_TERMS = { "latest", "look", "media", + "mean", + "meaning", + "meant", "nachrichten", + "nah", "news", "neueste", "of", @@ -79,11 +87,15 @@ GENERIC_QUERY_TERMS = { "outlet", "outlets", "recent", + "said", + "say", "search", "story", "stories", "the", + "this", "today", + "told", "top", "ubersetzung", "uebersetzung", @@ -93,6 +105,8 @@ GENERIC_QUERY_TERMS = { "what", "whats", "wie", + "you", + "your", "zur", } @@ -143,6 +157,8 @@ CURRENT_LOOKUP_NOISE_TITLE_PATTERNS = ( "dictionary", "englisch-deutsch", "english-german", + "meaning", + "what does", "worterbuch", ) @@ -175,6 +191,14 @@ def _term_aliases(term: str) -> List[str]: aliases.append(term[:-3]) if term.endswith("isch") and len(term) > 6: aliases.append(term[:-4]) + if term == "libanon": + aliases.append("lebanon") + if term == "lebanese": + aliases.append("lebanon") + if term == "agreement": + aliases.extend(["deal", "accord", "framework"]) + if term == "war": + aliases.extend(["fighting", "conflict", "ceasefire", "cessation"]) return [alias for alias in aliases if len(alias) >= 3] @@ -244,7 +268,7 @@ def _query_is_too_generic(query: str, prompt: str) -> bool: def _clean_queries(prompt: str, generated: List[Any]) -> List[str]: cleaned: List[str] = [] seen = set() - for query in [*_fallback_queries(prompt), *generated]: + for query in [*generated, *_fallback_queries(prompt)]: text = " ".join(str(query or "").split()).strip() if not text or _query_is_too_generic(text, prompt): continue