add ocr example, modify email example

This commit is contained in:
yzlin 2024-02-08 00:05:00 +08:00
parent d2bf1c4547
commit d2f10ea90c
5 changed files with 37 additions and 60 deletions

View file

@ -4,17 +4,23 @@
@Author : Tuo Zhou
@File : email_summary.py
"""
import os
from metagpt.roles.ci.code_interpreter import CodeInterpreter
async def main():
# For email response prompt
email_account = "your_email_account"
# prompt = f"""I will give you your Outlook email account({email_account}) and password(email_password item in the environment variable). You need to find the latest email in my inbox with the sender's suffix @qq.com and reply to him "Thank you! I have received your email~"""""
prompt = f"""I will give you your Outlook email account({email_account}) and password(email_password item in the environment variable).
# your password will stay only on your device and not go to LLM api
os.environ["email_password"] = "your_email_password"
### Prompt for automatic email reply, uncomment to try this too ###
# prompt = f"""I will give you your Outlook email account ({email_account}) and password (email_password item in the environment variable). You need to find the latest email in my inbox with the sender's suffix @gmail.com and reply "Thank you! I have received your email~"""""
### Prompt for automatic email summary ###
prompt = f"""I will give you your Outlook email account ({email_account}) and password (email_password item in the environment variable).
Firstly, Please help me fetch the latest 5 senders and full letter contents.
Then, summarize each of the 5 emails into one sentence(you can do this by yourself, no need import other models to do this) and output them in a markdown format."""
Then, summarize each of the 5 emails into one sentence (you can do this by yourself, no need to import other models to do this) and output them in a markdown format."""
ci = CodeInterpreter(use_tools=True)

View file

@ -0,0 +1,19 @@
from metagpt.roles.ci.code_interpreter import CodeInterpreter
async def main():
# Notice: pip install metagpt[ocr] before using this example
image_path = "image.jpg"
language = "English"
requirement = f"""This is a {language} invoice image.
Your goal is to perform OCR on images using PaddleOCR, then extract the total amount from ocr text results, and finally save as table. Image path: {image_path}.
NOTE: The environments for Paddle and PaddleOCR are all ready and has been fully installed."""
ci = CodeInterpreter()
await ci.run(requirement)
if __name__ == "__main__":
import asyncio
asyncio.run(main())