mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-11-06 13:12:27 +01:00
Require explicit initial search queries rather than copying whole requests
This commit is contained in:
@@ -3460,15 +3460,13 @@ def preserve_requested_web_recency(name, args, *, user_text='', prior_search_int
|
|||||||
user = str(user_text or '')
|
user = str(user_text or '')
|
||||||
query = str(args.get('query') or '').strip()
|
query = str(args.get('query') or '').strip()
|
||||||
if not query:
|
if not query:
|
||||||
if prior_search_intents:
|
raise ValueError(
|
||||||
raise ValueError(
|
'web_search requires an explicit nonempty query. '
|
||||||
'web_search requires an explicit query for a follow-up. Supply a '
|
+ ('Supply a specific missing fact, entity, or corroboration question '
|
||||||
'specific missing fact, entity, or corroboration question based on '
|
'based on the evidence already returned; do not repeat the original query.'
|
||||||
'the evidence already returned; do not repeat the original query.'
|
if prior_search_intents else
|
||||||
)
|
'Supply the subject to search for, not the full conversation or answer-format instructions.')
|
||||||
query = re.sub(r'\s+', ' ', user).strip().rstrip('?.!')
|
)
|
||||||
if not query:
|
|
||||||
return args
|
|
||||||
normalized = dict(args)
|
normalized = dict(args)
|
||||||
# Keep the user's explicit news intent when a model rewrites it to a
|
# Keep the user's explicit news intent when a model rewrites it to a
|
||||||
# subject plus "today". Freshness alone does not select the news vertical.
|
# subject plus "today". Freshness alone does not select the news vertical.
|
||||||
|
|||||||
@@ -2018,12 +2018,13 @@ def test_current_search_arguments_repair_stale_year_and_add_freshness():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('missing_query', [{}, {'query': ''}, {'query': ' ', 'time_filter': 'day'}])
|
@pytest.mark.parametrize('missing_query', [{}, {'query': ''}, {'query': ' ', 'time_filter': 'day'}])
|
||||||
def test_missing_refinement_query_is_not_fabricated(missing_query):
|
@pytest.mark.parametrize('prior_intents', [[], ['ai news']])
|
||||||
with pytest.raises(ValueError, match='explicit query for a follow-up'):
|
def test_missing_refinement_query_is_not_fabricated(missing_query, prior_intents):
|
||||||
|
with pytest.raises(ValueError, match='explicit nonempty query'):
|
||||||
preserve_requested_web_recency(
|
preserve_requested_web_recency(
|
||||||
'web_search', missing_query,
|
'web_search', missing_query,
|
||||||
user_text='serch latest ai news pls',
|
user_text='serch latest ai news pls',
|
||||||
prior_search_intents=['ai news'],
|
prior_search_intents=prior_intents,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user