MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / extract_doc_token

Function extract_doc_token

agents/reading-agent/main.py:488–513  ·  view source on GitHub ↗

Best-effort extract the document token from different Feishu response shapes.

(doc_info: Dict[str, Any])

Source from the content-addressed store, hash-verified

486
487def extract_doc_token(doc_info: Dict[str, Any]) -> Optional[str]:
488 """Best-effort extract the document token from different Feishu response shapes."""
489 if not isinstance(doc_info, dict):
490 return None
491
492 for candidate in (doc_info.get("obj_token"), doc_info.get("document_id"), doc_info.get("token")):
493 if isinstance(candidate, str) and candidate.strip():
494 return candidate.strip()
495
496 data = doc_info.get("data")
497 if isinstance(data, dict):
498 for candidate in (data.get("obj_token"), data.get("document_id"), data.get("token")):
499 if isinstance(candidate, str) and candidate.strip():
500 return candidate.strip()
501
502 document = data.get("document")
503 if isinstance(document, dict):
504 for candidate in (
505 document.get("obj_token"),
506 document.get("document_id"),
507 document.get("token"),
508 ):
509 if isinstance(candidate, str) and candidate.strip():
510 return candidate.strip()
511
512 return None
513
514
515def _load_arxiv_fetcher():
516 return importlib.import_module("skills.arxiv-fetcher.scripts.fetch_arxiv")

Callers 2

create_reading_reportFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected