MCPcopy Create free account
hub / github.com/algorithmicsuperintelligence/optillm / extract_query

Function extract_query

optillm/plugins/memory_plugin.py:36–50  ·  view source on GitHub ↗
(text: str)

Source from the content-addressed store, hash-verified

34 return [self.items[i] for i in top_indices]
35
36def extract_query(text: str) -> Tuple[str, str]:
37 query_index = text.rfind("Query:")
38
39 if query_index != -1:
40 context = text[:query_index].strip()
41 query = text[query_index + 6:].strip()
42 else:
43 sentences = re.split(r'(?<=[.!?])\s+', text.strip())
44 if len(sentences) > 1:
45 context = ' '.join(sentences[:-1])
46 query = sentences[-1]
47 else:
48 context = text
49 query = "What is the main point of this text?"
50 return query, context
51
52def classify_margin(margin):
53 return margin.startswith("YES#")

Callers 1

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected