mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-10 08:52:21 +02:00
unify broad web briefing semantics
This commit is contained in:
@@ -30,7 +30,8 @@ from src.tool_schemas import (
|
||||
)
|
||||
from src.tool_types import ToolBlock
|
||||
from src.turn_contract import (
|
||||
FAMILY_TOOLS, required_read_operation_for_request, targets_bound_editor_request,
|
||||
FAMILY_TOOLS, broad_web_briefing_request, required_read_operation_for_request,
|
||||
targets_bound_editor_request,
|
||||
)
|
||||
from src.prompt_security import untrusted_context_message
|
||||
from src.model_profiles import (
|
||||
@@ -890,18 +891,7 @@ def contentless_final_response(content):
|
||||
|
||||
def broad_current_web_request(user_text):
|
||||
"""Whether the user requested a broad current-information briefing."""
|
||||
request = str(user_text or '')
|
||||
return bool(
|
||||
(
|
||||
re.search(r'\b(?:latest|recent|current|today(?:\'s)?)\b', request, re.I)
|
||||
and re.search(r'\b(?:info(?:rmation)?|news|nees|updates?)\b', request, re.I)
|
||||
)
|
||||
or re.search(
|
||||
r"\b(?:what(?:'s|\s+is)|anything|something)\s+new\b",
|
||||
request,
|
||||
re.I,
|
||||
)
|
||||
)
|
||||
return broad_web_briefing_request(user_text)
|
||||
|
||||
|
||||
def incomplete_broad_web_answer(content, user_text):
|
||||
|
||||
@@ -3948,6 +3948,35 @@ def recently_read_gallery(history: Iterable, *, user_turns: int = 4) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def broad_web_briefing_request(message: str) -> bool:
|
||||
"""Recognize requests that need broad, current, multi-source Web evidence."""
|
||||
text = _normalize_request_lead(message)
|
||||
if re.search(
|
||||
r"\b(?:what(?:'s|\s+is)\s+(?:new|happening)|anything\s+new|"
|
||||
r"catch\s+me\s+up|give\s+me\s+(?:an?\s+)?update|"
|
||||
r"what\s+should\s+i\s+know)\b",
|
||||
text,
|
||||
re.I,
|
||||
):
|
||||
return True
|
||||
if re.search(r"\b(?:news|headlines?|top\s+stories|news\s+roundup)\b", text, re.I):
|
||||
return True
|
||||
if (
|
||||
re.search(r"\b(?:latest|recent|current|today(?:'s)?|right\s+now)\b", text, re.I)
|
||||
and re.search(
|
||||
r"\b(?:developments?|updates?|trends?|breakthroughs?|events?|stories|"
|
||||
r"recommendations?|reviews?|best|compare|comparison)\b",
|
||||
text,
|
||||
re.I,
|
||||
)
|
||||
):
|
||||
return True
|
||||
return bool(
|
||||
re.search(r"\b(?:recommend|best)\b", text, re.I)
|
||||
and re.search(r"\b(?:current|latest|today|right\s+now|reviews?)\b", text, re.I)
|
||||
)
|
||||
|
||||
|
||||
def requested_capabilities(message: str, history: Iterable = (), *, active_document=False, workspace=False) -> frozenset[str]:
|
||||
"""Classify once; inherit a prior capability only for a referential follow-up."""
|
||||
raw_text = str(message or "").strip()
|
||||
@@ -3956,6 +3985,8 @@ def requested_capabilities(message: str, history: Iterable = (), *, active_docum
|
||||
text = lead["request"].strip()
|
||||
history = tuple(history)
|
||||
concrete_urls = re.findall(r"\bhttps?://[^\s<>\"']+", raw_text, re.I)
|
||||
if broad_web_briefing_request(text):
|
||||
return frozenset({"search_browser"})
|
||||
if re.search(r"\b(?:web_search|web_fetch)\b", raw_text, re.I):
|
||||
# Explicit native-tool requests are stronger than incidental domain
|
||||
# words in the research subject (for example, Git ``pull`` must not
|
||||
|
||||
Reference in New Issue
Block a user