Skip to content

Commit 93e1b52

Browse files
authored
Merge pull request #284 from algorithmicsuperintelligence/feat-fix-web-search
Feat fix web search
2 parents 84f80d0 + a5a9420 commit 93e1b52

File tree

3 files changed

+15
-25
lines changed

3 files changed

+15
-25
lines changed

optillm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Version information
2-
__version__ = "0.3.10"
2+
__version__ = "0.3.11"
33

44
# Import from server module
55
from .server import (

optillm/plugins/web_search_plugin.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -517,39 +517,29 @@ def extract_search_queries(text: str) -> List[str]:
517517
queries.append(cleaned)
518518

519519
# If no explicit patterns, use the text as a search query
520+
# Since the user explicitly invoked the web_search plugin, we should always search
520521
if not queries:
521522
# Check if this is a search command with empty query (e.g., "search for" with nothing after)
522523
search_prefixes = ["search for", "find information about", "look up", "research"]
523524
text_lower = text.lower().strip()
524-
525+
525526
# Don't use fallback if it's just a search prefix with nothing meaningful after
526527
is_empty_search = any(
527-
text_lower.startswith(prefix) and
528+
text_lower.startswith(prefix) and
528529
len(text_lower.replace(prefix, "").strip().strip('"\'')) < 2
529530
for prefix in search_prefixes
530531
)
531-
532-
if not is_empty_search:
533-
# Remove question marks and clean up
534-
cleaned_query = text.replace("?", "").strip()
535-
# Remove quotes from the query
536-
cleaned_query = cleaned_query.strip('"\'')
537-
538-
# If it looks like a question or search query, use it
539-
if cleaned_query and len(cleaned_query.split()) > 2:
532+
533+
if not is_empty_search and text.strip():
534+
# User explicitly invoked web_search plugin - send the full query
535+
cleaned_query = text.strip()
536+
537+
# Just basic cleanup: normalize whitespace (replace newlines with spaces)
538+
cleaned_query = ' '.join(cleaned_query.split())
539+
540+
# Final validation - must have some meaningful content
541+
if cleaned_query and len(cleaned_query) >= 3:
540542
queries.append(cleaned_query)
541-
else:
542-
# Clean up the text to make it search-friendly
543-
cleaned_query = re.sub(r'[^\w\s\.]', ' ', text) # Keep periods for version numbers
544-
cleaned_query = ' '.join(cleaned_query.split())
545-
# Remove quotes after regex cleaning
546-
cleaned_query = cleaned_query.strip('"\'')
547-
548-
if len(cleaned_query) > 100:
549-
# Take first 100 characters
550-
cleaned_query = cleaned_query[:100].rsplit(' ', 1)[0]
551-
if cleaned_query and len(cleaned_query) > 2: # Ensure minimum length
552-
queries.append(cleaned_query)
553543

554544
return queries
555545

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "optillm"
7-
version = "0.3.10"
7+
version = "0.3.11"
88
description = "An optimizing inference proxy for LLMs."
99
readme = "README.md"
1010
license = "Apache-2.0"

0 commit comments

Comments
 (0)