mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-27 14:25:20 +02:00
fix
This commit is contained in:
parent
67a325b05d
commit
571063069e
3 changed files with 6 additions and 1 deletions
|
|
@ -133,6 +133,7 @@ class GenerateTable(Action):
|
|||
name: str = "GenerateTable"
|
||||
context: Optional[str] = None
|
||||
llm: BaseGPTAPI = Field(default_factory=LLM)
|
||||
language: str = "ch"
|
||||
|
||||
async def run(self, ocr_results: list, filename: str, *args, **kwargs) -> dict[str, str]:
|
||||
"""Processes OCR results, extracts invoice information, generates a table, and saves it as an Excel file.
|
||||
|
|
|
|||
|
|
@ -90,6 +90,9 @@ class InvoiceOCRAssistant(Role):
|
|||
self._rc.todo = None
|
||||
content = INVOICE_OCR_SUCCESS
|
||||
resp = OCRResults(ocr_result=json.dumps(resp))
|
||||
msg = Message(content=content, instruct_content=resp)
|
||||
self._rc.memory.add(msg)
|
||||
return await super().react()
|
||||
elif isinstance(todo, GenerateTable):
|
||||
ocr_results: OCRResults = msg.instruct_content
|
||||
resp = await todo.run(json.loads(ocr_results.ocr_result), self.filename)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
@File : test_invoice_ocr_assistant.py
|
||||
"""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import pandas as pd
|
||||
|
|
@ -59,4 +60,4 @@ async def test_invoice_ocr_assistant(
|
|||
invoice_table_path = Path.cwd() / invoice_table_path
|
||||
df = pd.read_excel(invoice_table_path)
|
||||
dict_result = df.to_dict(orient="records")
|
||||
assert dict_result == expected_result
|
||||
assert json.dumps(dict_result) == json.dumps(expected_result)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue