mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
Merge pull request #1355 from huang-jl/fix-ocr-assistant
fix: invoice ocr assistant
This commit is contained in:
commit
f85bb7930b
1 changed files with 5 additions and 7 deletions
|
|
@ -80,19 +80,17 @@ class InvoiceOCRAssistant(Role):
|
|||
raise Exception("Invoice file not uploaded")
|
||||
|
||||
resp = await todo.run(file_path)
|
||||
actions = list(self.actions)
|
||||
if len(resp) == 1:
|
||||
# Single file support for questioning based on OCR recognition results
|
||||
self.set_actions([GenerateTable, ReplyQuestion])
|
||||
actions.extend([GenerateTable, ReplyQuestion])
|
||||
self.orc_data = resp[0]
|
||||
else:
|
||||
self.set_actions([GenerateTable])
|
||||
|
||||
self.set_todo(None)
|
||||
actions.append(GenerateTable)
|
||||
self.set_actions(actions)
|
||||
self.rc.max_react_loop = len(self.actions)
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue