MCPcopy Create free account
hub / github.com/Open-Quant/openquant / afml_get_context

Function afml_get_context

scripts/afml_mcp_server.py:249–281  ·  view source on GitHub ↗
(
    query: str,
    top_k: int = 4,
    window: int = 1,
    chapter: str = "",
    section: str = "",
    semantic_weight: float = 0.86,
)

Source from the content-addressed store, hash-verified

247 ),
248)
249def afml_get_context(
250 query: str,
251 top_k: int = 4,
252 window: int = 1,
253 chapter: str = "",
254 section: str = "",
255 semantic_weight: float = 0.86,
256) -> dict[str, Any]:
257 if window < 0:
258 window = 0
259 if window > 5:
260 window = 5
261
262 hits = _score_results(
263 query=query,
264 top_k=top_k,
265 chapter=chapter,
266 section=section,
267 semantic_weight=semantic_weight,
268 )
269
270 contexts: list[dict[str, Any]] = []
271 for hit in hits:
272 bundle = _chunk_with_neighbors(hit["chunk_id"], window=window)
273 contexts.append({"hit": hit, "context": bundle})
274
275 return {
276 "query": query,
277 "top_k": top_k,
278 "window": window,
279 "filters": {"chapter": chapter, "section": section},
280 "contexts": contexts,
281 }
282
283
284if __name__ == "__main__":

Callers 1

cmd_evidenceFunction · 0.90

Calls 3

_score_resultsFunction · 0.85
_chunk_with_neighborsFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected