Create a clean structure for document description generation, excluding unnecessary fields like 'text'.
(structure)
| 597 | |
| 598 | |
| 599 | def create_clean_structure_for_description(structure): |
| 600 | """ |
| 601 | Create a clean structure for document description generation, |
| 602 | excluding unnecessary fields like 'text'. |
| 603 | """ |
| 604 | if isinstance(structure, dict): |
| 605 | clean_node = {} |
| 606 | # Only include essential fields for description |
| 607 | for key in ['title', 'node_id', 'summary', 'prefix_summary']: |
| 608 | if key in structure: |
| 609 | clean_node[key] = structure[key] |
| 610 | |
| 611 | # Recursively process child nodes |
| 612 | if 'nodes' in structure and structure['nodes']: |
| 613 | clean_node['nodes'] = create_clean_structure_for_description(structure['nodes']) |
| 614 | |
| 615 | return clean_node |
| 616 | elif isinstance(structure, list): |
| 617 | return [create_clean_structure_for_description(item) for item in structure] |
| 618 | else: |
| 619 | return structure |
| 620 | |
| 621 | |
| 622 | def generate_doc_description(structure, model=None): |
no outgoing calls
no test coverage detected