mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
fix(websearch): preserve quotes for unwrapped search queries
Signed-off-by: agustin18 <agustinsaiz02@gmail.com>
This commit is contained in:
parent
b94efc3399
commit
c65292e699
2 changed files with 13 additions and 2 deletions
|
|
@ -303,8 +303,11 @@ class WebSearchInterceptionLogger(CustomLogger):
|
|||
Strip known instructional prefixes so the search backend receives only
|
||||
the intended search terms rather than query wrapper keywords.
|
||||
"""
|
||||
cleaned = _CLAUDE_CODE_SEARCH_PREFIX_RE.sub("", raw_message).strip()
|
||||
if (cleaned.startswith('"') and cleaned.endswith('"')) or (cleaned.startswith("'") and cleaned.endswith("'")):
|
||||
prefix = _CLAUDE_CODE_SEARCH_PREFIX_RE.match(raw_message)
|
||||
cleaned = (raw_message[prefix.end() :] if prefix else raw_message).strip()
|
||||
if prefix and (
|
||||
(cleaned.startswith('"') and cleaned.endswith('"')) or (cleaned.startswith("'") and cleaned.endswith("'"))
|
||||
):
|
||||
cleaned = cleaned[1:-1].strip()
|
||||
return cleaned if cleaned else raw_message.strip()
|
||||
|
||||
|
|
|
|||
|
|
@ -417,6 +417,14 @@ class TestShortCircuitEntryPoint:
|
|||
"Search for Claude Code releases",
|
||||
"Search for Claude Code releases",
|
||||
),
|
||||
(
|
||||
'"LiteLLM latest version release"',
|
||||
'"LiteLLM latest version release"',
|
||||
),
|
||||
(
|
||||
"'fastapi SSE streaming'",
|
||||
"'fastapi SSE streaming'",
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_short_circuits_strips_claude_code_instructional_prefix(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue