mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-04-26 16:46:21 +02:00
consolidate async calls
This commit is contained in:
parent
3f174796fa
commit
6d6e92d56e
1 changed files with 25 additions and 22 deletions
|
|
@ -1071,7 +1071,8 @@ def page_index_main(doc, opt=None):
|
||||||
logger.info({'total_page_number': len(page_list)})
|
logger.info({'total_page_number': len(page_list)})
|
||||||
logger.info({'total_token': sum([page[1] for page in page_list])})
|
logger.info({'total_token': sum([page[1] for page in page_list])})
|
||||||
|
|
||||||
structure = asyncio.run(tree_parser(page_list, opt, doc=doc, logger=logger))
|
async def page_index_builder():
|
||||||
|
structure = await tree_parser(page_list, opt, doc=doc, logger=logger)
|
||||||
if opt.if_add_node_id == 'yes':
|
if opt.if_add_node_id == 'yes':
|
||||||
write_node_id(structure)
|
write_node_id(structure)
|
||||||
if opt.if_add_node_text == 'yes':
|
if opt.if_add_node_text == 'yes':
|
||||||
|
|
@ -1079,7 +1080,7 @@ def page_index_main(doc, opt=None):
|
||||||
if opt.if_add_node_summary == 'yes':
|
if opt.if_add_node_summary == 'yes':
|
||||||
if opt.if_add_node_text == 'no':
|
if opt.if_add_node_text == 'no':
|
||||||
add_node_text(structure, page_list)
|
add_node_text(structure, page_list)
|
||||||
asyncio.run(generate_summaries_for_structure(structure, model=opt.model))
|
await generate_summaries_for_structure(structure, model=opt.model)
|
||||||
if opt.if_add_node_text == 'no':
|
if opt.if_add_node_text == 'no':
|
||||||
remove_structure_text(structure)
|
remove_structure_text(structure)
|
||||||
if opt.if_add_doc_description == 'yes':
|
if opt.if_add_doc_description == 'yes':
|
||||||
|
|
@ -1094,6 +1095,8 @@ def page_index_main(doc, opt=None):
|
||||||
'structure': structure,
|
'structure': structure,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return asyncio.run(page_index_builder())
|
||||||
|
|
||||||
|
|
||||||
def page_index(doc, model=None, toc_check_page_num=None, max_page_num_each_node=None, max_token_num_each_node=None,
|
def page_index(doc, model=None, toc_check_page_num=None, max_page_num_each_node=None, max_token_num_each_node=None,
|
||||||
if_add_node_id=None, if_add_node_summary=None, if_add_doc_description=None, if_add_node_text=None):
|
if_add_node_id=None, if_add_node_summary=None, if_add_doc_description=None, if_add_node_text=None):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue