Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

fix

better629571063069eed
diff --git a/metagpt/actions/invoice_ocr.py b/metagpt/actions/invoice_ocr.py
index 11b4febc0..87f81371e 100644
--- a/metagpt/actions/invoice_ocr.py
+++ b/metagpt/actions/invoice_ocr.py
@@ -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.
diff --git a/metagpt/roles/invoice_ocr_assistant.py b/metagpt/roles/invoice_ocr_assistant.py
index 84e354c0e..3349a498f 100644
--- a/metagpt/roles/invoice_ocr_assistant.py
+++ b/metagpt/roles/invoice_ocr_assistant.py
@@ -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)
diff --git a/tests/metagpt/roles/test_invoice_ocr_assistant.py b/tests/metagpt/roles/test_invoice_ocr_assistant.py
index e5a570f53..ab3092004 100644
--- a/tests/metagpt/roles/test_invoice_ocr_assistant.py
+++ b/tests/metagpt/roles/test_invoice_ocr_assistant.py
@@ -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)