diff --git a/recipes/use_cases/email_agent/1.png b/recipes/use_cases/email_agent/1.png index 639c905c2cd4ffcf7fe866b43615e3d33001b03a..2793199db6173abc5446ea02024bf6fb70736ef6 100644 Binary files a/recipes/use_cases/email_agent/1.png and b/recipes/use_cases/email_agent/1.png differ diff --git a/recipes/use_cases/email_agent/2.png b/recipes/use_cases/email_agent/2.png index e80f894f1c30d15c67f134e2c156269b74825160..5b618ec0f8799ecdb173541e1de7d802f263948e 100644 Binary files a/recipes/use_cases/email_agent/2.png and b/recipes/use_cases/email_agent/2.png differ diff --git a/recipes/use_cases/email_agent/3.png b/recipes/use_cases/email_agent/3.png index d74b7d49d437290afeed4c6670e18635e6624384..fba755085564b4f9ecfc652de79a704eba849e54 100644 Binary files a/recipes/use_cases/email_agent/3.png and b/recipes/use_cases/email_agent/3.png differ diff --git a/recipes/use_cases/email_agent/README.md b/recipes/use_cases/email_agent/README.md index e5ce904710aec651422de79e5d0e7cf4877527f8..ae9961707b0a67a7c21cd7342d5311edee1e37b9 100644 --- a/recipes/use_cases/email_agent/README.md +++ b/recipes/use_cases/email_agent/README.md @@ -52,9 +52,9 @@ Yet another simple [summary](https://www.felicis.com/insight/the-agentic-web) by All in all (see [Resources](#resources) for even more info), agents are systems that take a high-level task, use an LLM as a reasoning and planning engine, with the help of contextual info and long-term memory if needed, to decide what actions to take, reflect and improve on the actions, and eventually execute those actions to accomplish the task. -It's time to see an agent app in action and enjoy some coding. Below is a preview of the questions or requests one may ask Emagent: +It's time to see an agent app in action and enjoy some coding. Below is a preview of the questions or requests one may ask the agent: -# Example Asks to Emagent +# Example Asks to Email Agent * do i have any emails with attachments? * what's the content of the email from LangSmith @@ -70,7 +70,10 @@ It's time to see an agent app in action and enjoy some coding. Below is a previe * how many emails do i have from xxx@gmail.com? * how about from yyy@gmail.com? -[Here](./examples_log.txt) is an example interaction log with Emagent. +Below are screenshots of some example interactions with the agent: + + + # Setup and Installation @@ -99,14 +102,14 @@ This will download a quantized version of Llama 3.1 of the size 4.7GB. First, create a Conda or virtual env: ``` -conda create -n emagent python=3.10 -conda activate emagent +conda create -n emailagent python=3.10 +conda activate emailagent ``` or ``` -python -m venv emagent -source emagent/bin/activate # on Linux, macOS: -source emagent\Scripts\activate # on Windows +python -m venv emailagent +source emailagent/bin/activate # on Linux, macOS: +source emailagent\Scripts\activate # on Windows ``` Then install the required Python libraries: @@ -116,9 +119,9 @@ cd llama-recipes/recipes/use_cases/email_agent pip install -r requirements.txt ``` -# Run Emagent +# Run Email Agent -To run Emagent, you need to first copy the `credentials.json` file downloaded and renamed above in Step 6 of Enable Gmail API to the emagent folder, then run: +To run the agent, you need to first copy the `credentials.json` file downloaded and renamed above in Step 6 of Enable Gmail API to the email_agent folder, then run: ``` python main.py --gmail <your_gmail_address> ``` diff --git a/recipes/use_cases/email_agent/examples_log.txt b/recipes/use_cases/email_agent/examples_log.txt deleted file mode 100644 index 15d01e7dc68b0ed2e453f68e742577cc1441304f..0000000000000000000000000000000000000000 --- a/recipes/use_cases/email_agent/examples_log.txt +++ /dev/null @@ -1,230 +0,0 @@ -python main.py --gmail=gmagent_tester1@gmail.com -Hello! I'm Gmagent, your friendly Gmail assistant. I'm here to help you with any Gmail-related tasks. What can I do for you today? Do you need help checking email, composing a new message, or perhaps something else? - -Your ask: do i have any emails with attachments? - -------------------------- -Calling Llama... - -Llama returned: {'function_name': 'list_emails', 'parameters': {'query': 'has:attachment'}}. - -Calling tool to access Gmail API: list_emails, {'query': 'has:attachment'}... - -Tool calling returned: [{'message_id': '1936ef72ad3f30e8', 'sender': 'gmagent_tester1@gmail.com', 'subject': 'Fwd: papers to read', 'received_time': '2024-11-27 10:51:51 PST'}, {'message_id': '1936b819706a4923', 'sender': 'Jeff Tang <gmagent_tester2@gmail.com>', 'subject': 'papers to read', 'received_time': '2024-11-26 18:44:19 PST'}, {'message_id': '18fa7f38f83197d3', 'sender': 'LangSmith <noreply@langchain.com>', 'subject': 'New Data Retention policy for LangSmith', 'received_time': '2024-05-23 17:14:22 PDT'}] - -------------------------- - -Gmagent: I found 3 emails matching your query: -1. From: gmagent_tester1@gmail.com, Subject: Fwd: papers to read, Received on: 2024-11-27 10:51:51 PST -2. From: Jeff Tang <gmagent_tester2@gmail.com>, Subject: papers to read, Received on: 2024-11-26 18:44:19 PST -3. From: LangSmith <noreply@langchain.com>, Subject: New Data Retention policy for LangSmith, Received on: 2024-05-23 17:14:22 PDT - - -Your ask: what's the content of the email from LangSmith - -------------------------- -Calling Llama... - -Llama returned: {'function_name': 'get_email_detail', 'parameters': {'detail': 'body', 'which': 'from <sender info>'}}. - -Calling tool to access Gmail API: get_email_detail, {'detail': 'body', 'which': '18fa7f38f83197d3'}... - -Tool calling returned: New Data Retention policy for LangSmith -Hi Jeff, -You are receiving this email because you have an active account on LangSmith. We are transitioning to a new data retention strategy that limits the length of time trace data is stored in LangSmith. -Effective with traces received on or after Wednesday, May 22, all traces stored in LangSmith now have a maximum retention of 400 days from the time of ingest. -For more information about this change please visit the LangSmith Docs. -If after visiting the docs you still have additional questions, please reach out to LangSmith Support via support@langchain.dev or, if you are an Enterprise plan customer, your dedicated Slack channel. - -------------------------- - -Gmagent: New Data Retention policy for LangSmith -Hi Jeff, -You are receiving this email because you have an active account on LangSmith. We are transitioning to a new data retention strategy that limits the length of time trace data is stored in LangSmith. -Effective with traces received on or after Wednesday, May 22, all traces stored in LangSmith now have a maximum retention of 400 days from the time of ingest. -For more information about this change please visit the LangSmith Docs. -If after visiting the docs you still have additional questions, please reach out to LangSmith Support via support@langchain.dev or, if you are an Enterprise plan customer, your dedicated Slack channel. - - - - - - - - -Unsubscribe - -Your ask: do i have emails with attachment larger than 1mb? - -------------------------- -Calling Llama... - -Llama returned: {'function_name': 'list_emails', 'parameters': {'query': 'has:attachment larger:1mb'}}. - -Calling tool to access Gmail API: list_emails, {'query': 'has:attachment larger:1mb'}... - -Tool calling returned: [{'message_id': '1936ef72ad3f30e8', 'sender': 'gmagent_tester1@gmail.com', 'subject': 'Fwd: papers to read', 'received_time': '2024-11-27 10:51:51 PST'}, {'message_id': '1936b819706a4923', 'sender': 'Jeff Tang <gmagent_tester2@gmail.com>', 'subject': 'papers to read', 'received_time': '2024-11-26 18:44:19 PST'}] - -------------------------- - -Gmagent: I found 2 emails matching your query: -1. From: gmagent_tester1@gmail.com, Subject: Fwd: papers to read, Received on: 2024-11-27 10:51:51 PST -2. From: Jeff Tang <gmagent_tester2@gmail.com>, Subject: papers to read, Received on: 2024-11-26 18:44:19 PST - - -Your ask: what kind of attachments for the email with subject papers to read? - -------------------------- -Calling Llama... - -Llama returned: {'function_name': 'get_email_detail', 'parameters': {'detail': 'attachment', 'which': 'subject papers to read'}}. - -Calling tool to access Gmail API: get_email_detail, {'detail': 'attachment', 'which': '1936b819706a4923'}... - -Tool calling returned: thinking_llm.pdf - 1115430 bytes -logic-of-thought.pdf - 1719126 bytes - - -------------------------- - -Gmagent: thinking_llm.pdf - 1115430 bytes -logic-of-thought.pdf - 1719126 bytes - - -Your ask: give me a summary of the pdf thinking_llm.pdf - -------------------------- -Calling Llama... - -Llama returned: {'function_name': 'get_pdf_summary', 'parameters': {'file_name': 'thinking_llm.pdf'}}. - -Calling tool to access Gmail API: get_pdf_summary, {'file_name': 'thinking_llm.pdf'}... - -PDF text length: 80464 - -Calling Llama 31 to generate a summary... - -Tool calling returned: It appears that you've provided several examples of responses generated by a model, along with some analysis and comparisons. - -From what I can see, these examples illustrate various aspects of model performance, including: - -1. **Inconsistent or incorrect outputs**: In some cases, the model generates responses that are not accurate or consistent (e.g., Examples 17-19). -2. **Self-correction in math tasks**: The model sometimes makes mistakes but then corrects them based on further thought and analysis (e.g., Example 20). -3. **Improved performance with specific prompts**: Using specific prompts can help the model generate more accurate or helpful responses, especially in cases where it initially made a mistake (e.g., Examples 17-19). -4. **Comparison to direct models**: The TPO model's ability to correct its own mistakes and generate more accurate responses is highlighted through comparisons with direct models (e.g., Example 20). - -These examples are likely from the report you mentioned, which explores the performance of a sequence-to-sequence model for generating natural language responses. - -If you'd like to discuss any specific points or ask questions about these examples, I'm here to help! - -------------------------- - -Gmagent: It appears that you've provided several examples of responses generated by a model, along with some analysis and comparisons. - -From what I can see, these examples illustrate various aspects of model performance, including: - -1. **Inconsistent or incorrect outputs**: In some cases, the model generates responses that are not accurate or consistent (e.g., Examples 17-19). -2. **Self-correction in math tasks**: The model sometimes makes mistakes but then corrects them based on further thought and analysis (e.g., Example 20). -3. **Improved performance with specific prompts**: Using specific prompts can help the model generate more accurate or helpful responses, especially in cases where it initially made a mistake (e.g., Examples 17-19). -4. **Comparison to direct models**: The TPO model's ability to correct its own mistakes and generate more accurate responses is highlighted through comparisons with direct models (e.g., Example 20). - -These examples are likely from the report you mentioned, which explores the performance of a sequence-to-sequence model for generating natural language responses. - -If you'd like to discuss any specific points or ask questions about these examples, I'm here to help! - -Your ask: Draft an email to gmagent_tester2@meta.com saying working on it and will keep you updated. thanks for your patience. - -------------------------- -Calling Llama... - -Llama returned: {'function_name': 'create_draft', 'parameters': {'action': 'new', 'to': 'gmagent_tester2@meta.com', 'subject': 'Update on [Your Project]', 'body': 'Hi Jeff,\\n\\nI wanted to touch base with you regarding [Your Project]. I am currently working on it and will keep you updated. Thank you for your patience.\\n\\nBest regards,'}}. - -Calling tool to access Gmail API: create_draft, {'action': 'new', 'to': 'gmagent_tester2@meta.com', 'subject': 'Update on [Your Project]', 'body': 'Hi Jeff,\\n\\nI wanted to touch base with you regarding [Your Project]. I am currently working on it and will keep you updated. Thank you for your patience.\\n\\nBest regards,'}... -Draft created with ID: r5930232887125763038 - -Tool calling returned: r5930232887125763038 - -------------------------- - -Gmagent: Draft created. - -Your ask: send the draft - -------------------------- -Calling Llama... - -Llama returned: {'function_name': 'send_draft', 'parameters': {'id': '...'}}. - -Calling tool to access Gmail API: send_draft, {'id': 'r5930232887125763038'}... - -Tool calling returned: Draft sent with email ID: 1936fc3db1993629 - -------------------------- - -Gmagent: Draft sent with email ID: 1936fc3db1993629 - -Your ask: do i have any emails with attachment larger than 10mb? - -------------------------- -Calling Llama... - -Llama returned: {'function_name': 'list_emails', 'parameters': {'query': 'has:attachment larger:10mb'}}. - -Calling tool to access Gmail API: list_emails, {'query': 'has:attachment larger:10mb'}... - -Tool calling returned: [] - -------------------------- - -Gmagent: I couldn't find any such emails. What else would you like to do? - -Your ask: how about 5mb - -------------------------- -Calling Llama... - -Llama returned: {'function_name': 'list_emails', 'parameters': {'query': 'has:attachment larger:5mb'}}. - -Calling tool to access Gmail API: list_emails, {'query': 'has:attachment larger:5mb'}... - -Tool calling returned: [{'message_id': '1936fce85e88a3ef', 'sender': 'Jeff Tang <gmagent_tester2@gmail.com>', 'subject': 'this is an interesting paper', 'received_time': '2024-11-27 14:46:50 PST'}] - -------------------------- - -Gmagent: I found 1 email matching your query: -1. From: Jeff Tang <gmagent_tester2@gmail.com>, Subject: this is an interesting paper, Received on: 2024-11-27 14:46:50 PST - - -Your ask: reply to the email saying thanks for sharing! - -------------------------- -Calling Llama... - -Llama returned: {'function_name': 'send_email', 'parameters': {'action': 'reply', 'to': 'gmagent_tester2@gmail.com', 'subject': 'Re: this is an interesting paper', 'body': 'Thanks for sharing!', 'email_id': '1936fce85e88a3ef'}}. - -Calling tool to access Gmail API: send_email, {'action': 'reply', 'to': 'gmagent_tester2@gmail.com', 'subject': 'Re: this is an interesting paper', 'body': 'Thanks for sharing!', 'email_id': '1936fce85e88a3ef'}... -Reply sent. Message ID: 1936fd65f9f24e70 - -Tool calling returned: None - -------------------------- - -Gmagent: Email sent. - -Your ask: forward the email to gmagent_tester2@meta.com - -------------------------- -Calling Llama... - -Llama returned: {'function_name': 'send_email', 'parameters': {'action': 'forward', 'to': 'gmagent_tester2@meta.com', 'subject': 'this is an interesting paper', 'body': '', 'email_id': '1936fce85e88a3ef'}}. - -Calling tool to access Gmail API: send_email, {'action': 'forward', 'to': 'gmagent_tester2@meta.com', 'subject': 'this is an interesting paper', 'body': '', 'email_id': '1936fce85e88a3ef'}... -Message forwarded successfully! Message ID: 1936fdd039c68451 - -Tool calling returned: None - -------------------------- - -Gmagent: Email sent. - -Your ask: