MCPcopy
hub / github.com/VectifyAI/PageIndex / create_clean_structure_for_description

Function create_clean_structure_for_description

pageindex/utils.py:599–619  ·  view source on GitHub ↗

Create a clean structure for document description generation, excluding unnecessary fields like 'text'.

(structure)

Source from the content-addressed store, hash-verified

597
598
599def 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
622def generate_doc_description(structure, model=None):

Callers 2

page_index_builderFunction · 0.85
md_to_treeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected