mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-11-05 12:42:20 +01:00
Reject missing follow-up queries instead of fabricating research intent
This commit is contained in:
@@ -3459,9 +3459,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:
|
||||||
query = re.sub(r'\s+', ' ', user).strip().rstrip('?.!')
|
|
||||||
if prior_search_intents:
|
if prior_search_intents:
|
||||||
query += ' corroborating analysis authoritative sources'
|
raise ValueError(
|
||||||
|
'web_search requires an explicit query for a follow-up. Supply a '
|
||||||
|
'specific missing fact, entity, or corroboration question based on '
|
||||||
|
'the evidence already returned; do not repeat the original query.'
|
||||||
|
)
|
||||||
|
query = re.sub(r'\s+', ' ', user).strip().rstrip('?.!')
|
||||||
if not query:
|
if not query:
|
||||||
return args
|
return args
|
||||||
normalized = dict(args)
|
normalized = dict(args)
|
||||||
|
|||||||
@@ -2017,17 +2017,14 @@ def test_current_search_arguments_repair_stale_year_and_add_freshness():
|
|||||||
assert args['time_filter'] == 'day'
|
assert args['time_filter'] == 'day'
|
||||||
|
|
||||||
|
|
||||||
def test_missing_refinement_query_is_grounded_in_user_request():
|
@pytest.mark.parametrize('missing_query', [{}, {'query': ''}, {'query': ' ', 'time_filter': 'day'}])
|
||||||
args = preserve_requested_web_recency(
|
def test_missing_refinement_query_is_not_fabricated(missing_query):
|
||||||
'web_search',
|
with pytest.raises(ValueError, match='explicit query for a follow-up'):
|
||||||
{'time_filter': 'day'},
|
preserve_requested_web_recency(
|
||||||
user_text='What are the latest important AI developments?',
|
'web_search', missing_query,
|
||||||
prior_search_intents=['important ai developments'],
|
user_text='serch latest ai news pls',
|
||||||
)
|
prior_search_intents=['ai news'],
|
||||||
|
)
|
||||||
assert 'AI developments' in args['query']
|
|
||||||
assert 'corroborating analysis' in args['query']
|
|
||||||
assert args['time_filter'] == 'day'
|
|
||||||
|
|
||||||
|
|
||||||
def test_official_manual_does_not_invent_pdf_requirement():
|
def test_official_manual_does_not_invent_pdf_requirement():
|
||||||
|
|||||||
Reference in New Issue
Block a user