(section_title, content, model=None)
| 738 | |
| 739 | ################### fix incorrect toc ######################################################### |
| 740 | async def single_toc_item_index_fixer(section_title, content, model=None): |
| 741 | toc_extractor_prompt = """ |
| 742 | You are given a section title and several pages of a document, your job is to find the physical index of the start page of the section in the partial document. |
| 743 | |
| 744 | The provided pages contains tags like <physical_index_X> and <physical_index_X> to indicate the physical location of the page X. |
| 745 | |
| 746 | Reply in a JSON format: |
| 747 | { |
| 748 | "thinking": <explain which page, started and closed by <physical_index_X>, contains the start of this section>, |
| 749 | "physical_index": "<physical_index_X>" (keep the format) |
| 750 | } |
| 751 | Directly return the final JSON structure. Do not output anything else.""" |
| 752 | |
| 753 | prompt = toc_extractor_prompt + '\nSection Title:\n' + str(section_title) + '\nDocument pages:\n' + content |
| 754 | response = await llm_acompletion(model=model, prompt=prompt) |
| 755 | json_content = extract_json(response) |
| 756 | return convert_physical_index_to_int(json_content['physical_index']) |
| 757 | |
| 758 | |
| 759 |
no test coverage detected