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

Function cmd_evidence

scripts/afml_docs_loop.py:392–525  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

390
391
392def cmd_evidence(args: argparse.Namespace) -> int:
393 state = read_state()
394 evidence_chapters: list[dict[str, Any]] = []
395 processed = 0
396
397 for chapter in state["chapters"]:
398 chapter_name = chapter["chapter"]
399 chapter_query = chapter.get("query") or chapter.get("theme") or chapter_name
400 chapter_search = afml_search(
401 query=chapter_query,
402 chapter=chapter_name,
403 top_k=args.top_k,
404 include_text=False,
405 )
406 chapter_hits = filter_hits_to_chapter(chapter_search.get("results", []), chapter_name)
407 chapter_anchor = summarize_hit(chapter_hits[0]) if chapter_hits else chapter.get("afml_anchor", {})
408 chapter["afml_anchor"] = chapter_anchor
409
410 chapter_evidence: dict[str, Any] = {
411 "chapter": chapter_name,
412 "query": chapter_query,
413 "anchor": chapter_anchor,
414 "sections": [],
415 }
416
417 for section in chapter["sections"]:
418 if args.only_pending and section["status"] != "pending":
419 continue
420 processed += 1
421
422 module = section["module"]
423 module_query = MODULE_QUERIES.get(module, module.replace("_", " "))
424 search_out = afml_search(
425 query=module_query,
426 chapter=chapter_name,
427 top_k=args.top_k,
428 include_text=False,
429 )
430 search_hits = filter_hits_to_chapter(search_out.get("results", []), chapter_name)
431
432 ctx_out = afml_get_context(
433 query=module_query,
434 chapter=chapter_name,
435 top_k=args.top_k_context,
436 window=args.window,
437 )
438 contexts = [
439 c for c in ctx_out.get("contexts", []) if chapter_eq(str(c.get("hit", {}).get("chapter", "")), chapter_name)
440 ]
441
442 primary_hit: dict[str, Any] = {}
443 if contexts:
444 primary_hit = contexts[0].get("hit", {})
445 elif search_hits:
446 primary_hit = search_hits[0]
447
448 if primary_hit:
449 section["afml_anchor"] = summarize_hit(primary_hit)

Callers

nothing calls this directly

Calls 10

afml_searchFunction · 0.90
afml_get_contextFunction · 0.90
read_stateFunction · 0.85
filter_hits_to_chapterFunction · 0.85
summarize_hitFunction · 0.85
chapter_eqFunction · 0.85
now_isoFunction · 0.85
recompute_chapter_statusFunction · 0.85
write_stateFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected