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

Callers 2

create_reading_reportFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected