add openai api call switch; fix ocr

This commit is contained in:
yzlin 2024-01-05 14:34:44 +08:00
parent ab04f610a3
commit 1249d12b6f
4 changed files with 30 additions and 22 deletions

View file

@ -88,6 +88,8 @@ class InvoiceOCR(Action):
async def _ocr(invoice_file_path: Path):
ocr = PaddleOCR(use_angle_cls=True, lang="ch", page_num=1)
ocr_result = ocr.ocr(str(invoice_file_path), cls=True)
for result in ocr_result[0]:
result[1] = (result[1][0], round(result[1][1], 2)) # round long confidence scores to reduce token costs
return ocr_result
async def run(self, file_path: Path, *args, **kwargs) -> list: