Return tree structure JSON with text fields removed (saves tokens).
(documents: dict, doc_id: str)
| 98 | |
| 99 | |
| 100 | def get_document_structure(documents: dict, doc_id: str) -> str: |
| 101 | """Return tree structure JSON with text fields removed (saves tokens).""" |
| 102 | doc_info = documents.get(doc_id) |
| 103 | if not doc_info: |
| 104 | return json.dumps({'error': f'Document {doc_id} not found'}) |
| 105 | structure = doc_info.get('structure', []) |
| 106 | structure_no_text = remove_fields(structure, fields=['text']) |
| 107 | return json.dumps(structure_no_text, ensure_ascii=False) |
| 108 | |
| 109 | |
| 110 | def get_page_content(documents: dict, doc_id: str, pages: str) -> str: |
no test coverage detected