Self-hosted AI workspace.
Python
Avoid invented publication windows on corrected version lookups
pewdiepie-archdaemoncf9cb7b90f81
diff --git a/src/clean_agent_preview.py b/src/clean_agent_preview.pyindex 17f8dde78..fab8aaf10 100644--- a/src/clean_agent_preview.py+++ b/src/clean_agent_preview.py@@ -3496,7 +3496,7 @@ def preserve_requested_web_recency(name, args, *, user_text='', prior_search_intrequested_window = requested_search_publication_window(user)if requested_window:normalized['time_filter'] = requested_window- elif reference_lookup_without_date_window(user):+ elif reference_lookup_without_date_window(user, query):# A model-generated publication cutoff must not hide still-current# reference pages when the user did not ask for recent publications.normalized.pop('time_filter', None)diff --git a/src/search_intent.py b/src/search_intent.pyindex e4b63d2b8..61070ff00 100644--- a/src/search_intent.py+++ b/src/search_intent.py@@ -2,11 +2,11 @@import re-def reference_lookup_without_date_window(text: str) -> bool:+def reference_lookup_without_date_window(text: str, query_hint: str = '') -> bool:"""Current reference information need not have been published recently."""reference = re.search(- r'\b(?:documentation|docs|manuals?|guides?|reference|installation|configuration)\b'- r'|\bprivacy\s+(?:features|settings|protections)\b', text, re.I,+ r'\b(?:documentation|docs|manuals?|guides?|reference|installation|configuration|versions?|releases?)\b'+ r'|\bprivacy\s+(?:features|settings|protections)\b', text + ' ' + query_hint, re.I,)publication = re.search(r'\b(?:published|publication|announced|released|news|headlines|recent|today|yesterday)\b'diff --git a/tests/test_search_publication_intent.py b/tests/test_search_publication_intent.pyindex 519c99e31..262072b1a 100644--- a/tests/test_search_publication_intent.py+++ b/tests/test_search_publication_intent.py@@ -38,6 +38,11 @@ def test_explicit_publication_constraints_are_preserved():assert args['time_filter'] == 'month'+def test_corrected_version_query_does_not_invent_a_date_window_for_typo_request():+ args = preserve_requested_web_recency('web_search', {'query': 'latest Python version', 'time_filter': 'month'}, user_text='latest pythno verison? official source pls')+ assert 'time_filter' not in args++def test_provider_does_not_silently_widen_news_window(monkeypatch):from services.search import providersseen = {}