MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / extract_query

Function extract_query

core/retrieval.py:39–57  ·  view source on GitHub ↗

Extract a compact search query from the user's message. Strips filler words, keeps technical terms and intent keywords. Capped at max_words to avoid over-querying the KB. Args: user_message: Raw user message max_words: Max query terms to keep Returns:

(user_message: str, max_words: int = 15)

Source from the content-addressed store, hash-verified

37
38
39def extract_query(user_message: str, max_words: int = 15) -> str:
40 """
41 Extract a compact search query from the user's message.
42
43 Strips filler words, keeps technical terms and intent keywords.
44 Capped at max_words to avoid over-querying the KB.
45
46 Args:
47 user_message: Raw user message
48 max_words: Max query terms to keep
49
50 Returns:
51 Space-separated query string
52 """
53 # Remove non-alphanumeric except spaces and common code chars
54 cleaned = re.sub(r"[^\w\s\.\-/_]", " ", user_message.lower())
55 words = cleaned.split()
56 query_words = [w for w in words if w not in _FILLER and len(w) > 2]
57 return " ".join(query_words[:max_words])
58
59
60def retrieve(user_message: str, budget_chars: int = None) -> str:

Callers 2

retrieveFunction · 0.85
retrieve_debugFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected