Skip to content

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

modify by comment

Zhou Tuo3369c9e53671
diff --git a/examples/email_summary.py b/examples/email_summary.py
index 0862991da..dd8dd8c8e 100644
--- a/examples/email_summary.py
+++ b/examples/email_summary.py
@@ -10,10 +10,11 @@ from metagpt.roles.ci.code_interpreter import CodeInterpreter
async def main():
# For email response prompt
- # prompt = """I will give you your Outlook email account([email protected]) and password(the outlook_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 = """I will give you your Outlook email account([email protected]) and password(outlook_email_password item in the environment variable).
- Firstly, Please help me present the latest 5 senders and full letter contents.
- Then, summarize each of the 5 emails into one sentence with Chinese(you can do this by yourself, don't need import other models to do this) and output them in a markdown format."""
+ 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).
+ 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."""
ci = CodeInterpreter(use_tools=True)
diff --git a/metagpt/tools/libs/email_login.py b/metagpt/tools/libs/email_login.py
index 77772e15a..8fd77274c 100644
--- a/metagpt/tools/libs/email_login.py
+++ b/metagpt/tools/libs/email_login.py
@@ -51,8 +51,8 @@ def email_login_imap(email_address, email_password):
# Attempt to log in to the email account
try:
mailbox = MailBox(imap_server).login(email_address, email_password)
- print("Login successful")
+ logger.info("Login successful")
return mailbox
except Exception as e:
- print(f"Login failed: {e}")
+ logger.error(f"Login failed: {e}")
return None
diff --git a/tests/metagpt/tools/libs/test_email_login.py b/tests/metagpt/tools/libs/test_email_login.py
index fd8d41506..c18d15c7d 100644
--- a/tests/metagpt/tools/libs/test_email_login.py
+++ b/tests/metagpt/tools/libs/test_email_login.py
@@ -1,5 +1,4 @@
import os
-from unittest.mock import Mock, patch
import pytest
@@ -16,14 +15,13 @@ incorrect_email_password = "incorrect_password"
@pytest.fixture
-def imap_server_setup():
- # Use patch to mock the behavior of MailBox from the correct module path
- with patch("metagpt.tools.libs.email_login.MailBox") as mock_mailbox:
- # Setup for successful login
- mock_mail_instance = Mock()
- mock_mail_instance.login.return_value = mock_mail_instance
- mock_mailbox.return_value = mock_mail_instance
- yield mock_mail_instance
+def imap_server_setup(mocker):
+ # Use the mocker fixture to mock the MailBox class
+ mock_mailbox = mocker.patch("metagpt.tools.libs.email_login.MailBox")
+ mock_mail_instance = mocker.Mock()
+ mock_mail_instance.login.return_value = mock_mail_instance
+ mock_mailbox.return_value = mock_mail_instance
+ return mock_mail_instance
def test_email_login_imap_success(imap_server_setup):