autogen/notebook/agentchat_auto_feedback_from_code_execution.ipynb

1079 lines
224 KiB
Plaintext
Raw Normal View History

{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"<!--\n",
"tags: [\"code generation\", \"debugging\"]\n",
"description: |\n",
" Use conversable language learning model agents to solve tasks and provide automatic feedback through a comprehensive example of writing, executing, and debugging Python code to compare stock price changes.\n",
"-->\n",
"\n",
"# Task Solving with Code Generation, Execution and Debugging\n",
"\n",
2023-09-16 16:34:16 +00:00
"AutoGen offers conversable LLM agents, which can be used to solve various tasks with human or automatic feedback, including tasks that require using tools via code.\n",
2023-09-08 10:07:19 -04:00
"Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n",
"\n",
"In this notebook, we demonstrate how to use `AssistantAgent` and `UserProxyAgent` to write code and execute the code. Here `AssistantAgent` is an LLM-based agent that can write Python code (in a Python coding block) for a user to execute for a given task. `UserProxyAgent` is an agent which serves as a proxy for the human user to execute the code written by `AssistantAgent`, or automatically execute the code. Depending on the setting of `human_input_mode` and `max_consecutive_auto_reply`, the `UserProxyAgent` either solicits feedback from the human user or returns auto-feedback based on the result of code execution (success or failure and corresponding outputs) to `AssistantAgent`. `AssistantAgent` will debug the code and suggest new code if the result contains error. The two agents keep communicating to each other until the task is done.\n",
"\n",
"\\:\\:\\:info Requirements\n",
"\n",
"Install `pyautogen`:\n",
"```bash\n",
2023-09-16 16:34:16 +00:00
"pip install pyautogen\n",
"```\n",
"\n",
"For more information, please refer to the [installation guide](/docs/installation/).\n",
"\n",
"\\:\\:\\:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"from typing import Dict, Union\n",
"\n",
"from IPython import get_ipython\n",
"from IPython.display import display, Image\n",
"\n",
2023-09-16 16:34:16 +00:00
"import autogen\n",
"\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"config_list = autogen.config_list_from_json(\n",
" \"OAI_CONFIG_LIST\",\n",
" # filter_dict={\n",
" # \"model\": [\"gpt-4\", \"gpt-4-0314\", \"gpt4\", \"gpt-4-32k\", \"gpt-4-32k-0314\", \"gpt-4-32k-v0314\"],\n",
" # },\n",
")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"\\:\\:\\:tip\n",
"\n",
"Learn more about the various ways to configure LLM endpoints [here](/docs/llm_endpoint_configuration).\n",
"\n",
"\\:\\:\\:"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example Task: Check Stock Price Change\n",
"\n",
2023-09-16 16:34:16 +00:00
"In the example below, let's see how to use the agents in AutoGen to write a python script and execute the script. This process involves constructing a `AssistantAgent` to serve as the assistant, along with a `UserProxyAgent` that acts as a proxy for the human user. In this example demonstrated below, when constructing the `UserProxyAgent`, we select the `human_input_mode` to \"NEVER\". This means that the `UserProxyAgent` will not solicit feedback from the human user. It stops replying when the limit defined by `max_consecutive_auto_reply` is reached, or when `is_termination_msg()` returns true for the received message."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
"\n",
"What date is today? Compare the year-to-date gain for META and TESLA.\n",
"\n",
"--------------------------------------------------------------------------------\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
"\n",
"To get the current date, we can use Python's `datetime` module. After that, we will need to retrieve the year-to-date (YTD) gain for both META (Meta Platforms, Inc.) and TESLA (Tesla, Inc.). We can do this by fetching the stock prices from the beginning of the year and the current stock prices, then calculating the percentage change.\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\n",
"First, let's write a Python script to get the current date:\n",
"\n",
"```python\n",
"# filename: get_current_date.py\n",
"\n",
"from datetime import datetime\n",
"\n",
"# Get the current date\n",
"current_date = datetime.now()\n",
"\n",
"# Print the current date in YYYY-MM-DD format\n",
"print(current_date.strftime('%Y-%m-%d'))\n",
"```\n",
"\n",
"Please save the above code in a file named `get_current_date.py` and execute it to get today's date. After that, we will proceed to the next step of fetching the stock data.\n",
"\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"--------------------------------------------------------------------------------\n",
"\u001b[31m\n",
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
"\n",
"exitcode: 0 (execution succeeded)\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"Code output: \n",
"2024-02-07\n",
"\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
"\n",
"Great, today's date is 2024-02-07. Now, let's move on to the next step, which is to fetch the stock prices for META and TESLA.\n",
"\n",
"We will use Python to retrieve the stock data. There are several financial data APIs available, but for this example, we'll use `yfinance`, which is a popular library that allows us to fetch historical market data from Yahoo Finance.\n",
"\n",
"First, we need to install the `yfinance` package. You can do this by running the following command:\n",
"\n",
"```sh\n",
"pip install yfinance\n",
"```\n",
"\n",
"After installing `yfinance`, we will write a Python script to fetch the YTD stock prices for META and TESLA and calculate the YTD gain. The YTD gain is calculated by comparing the current stock price to the stock price at the beginning of the year.\n",
"\n",
"Here's the Python script to do that:\n",
"\n",
"```python\n",
"# filename: ytd_stock_comparison.py\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\n",
"import yfinance as yf\n",
"from datetime import datetime\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\n",
"# Define the tickers for Meta Platforms, Inc. and Tesla, Inc.\n",
"tickers = [\"META\", \"TSLA\"]\n",
"\n",
"# Define the start of the year\n",
"start_of_year = datetime(datetime.now().year, 1, 1)\n",
"\n",
"# Fetch the stock data\n",
"meta_data = yf.download(tickers[0], start=start_of_year, end=datetime.now())\n",
"tesla_data = yf.download(tickers[1], start=start_of_year, end=datetime.now())\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\n",
"# Calculate the YTD gain for each stock\n",
"meta_ytd_gain = ((meta_data['Close'][-1] - meta_data['Close'][0]) / meta_data['Close'][0]) * 100\n",
"tesla_ytd_gain = ((tesla_data['Close'][-1] - tesla_data['Close'][0]) / tesla_data['Close'][0]) * 100\n",
"\n",
"# Print the YTD gain for each stock\n",
"print(f\"META YTD Gain: {meta_ytd_gain:.2f}%\")\n",
"print(f\"TESLA YTD Gain: {tesla_ytd_gain:.2f}%\")\n",
"```\n",
"\n",
"Please save the above code in a file named `ytd_stock_comparison.py` and execute it. This script will output the YTD gain for both META and TESLA stocks.\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[31m\n",
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is sh)...\u001b[0m\n",
"\u001b[31m\n",
">>>>>>>> EXECUTING CODE BLOCK 1 (inferred language is python)...\u001b[0m\n",
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
"\n",
"exitcode: 0 (execution succeeded)\n",
"Code output: \n",
"Requirement already satisfied: yfinance in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (0.2.36)\n",
"Requirement already satisfied: pandas>=1.3.0 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (2.2.0)\n",
"Requirement already satisfied: numpy>=1.16.5 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (1.26.3)\n",
"Requirement already satisfied: requests>=2.31 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (2.31.0)\n",
"Requirement already satisfied: multitasking>=0.0.7 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (0.0.11)\n",
"Requirement already satisfied: lxml>=4.9.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (5.1.0)\n",
"Requirement already satisfied: appdirs>=1.4.4 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (1.4.4)\n",
"Requirement already satisfied: pytz>=2022.5 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (2023.3.post1)\n",
"Requirement already satisfied: frozendict>=2.3.4 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (2.4.0)\n",
"Requirement already satisfied: peewee>=3.16.2 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (3.17.0)\n",
"Requirement already satisfied: beautifulsoup4>=4.11.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (4.12.3)\n",
"Requirement already satisfied: html5lib>=1.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (1.1)\n",
"Requirement already satisfied: soupsieve>1.2 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from beautifulsoup4>=4.11.1->yfinance) (2.5)\n",
"Requirement already satisfied: six>=1.9 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from html5lib>=1.1->yfinance) (1.16.0)\n",
"Requirement already satisfied: webencodings in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from html5lib>=1.1->yfinance) (0.5.1)\n",
"Requirement already satisfied: python-dateutil>=2.8.2 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from pandas>=1.3.0->yfinance) (2.8.2)\n",
"Requirement already satisfied: tzdata>=2022.7 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from pandas>=1.3.0->yfinance) (2023.4)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from requests>=2.31->yfinance) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from requests>=2.31->yfinance) (3.6)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from requests>=2.31->yfinance) (2.1.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from requests>=2.31->yfinance) (2023.11.17)\n",
"\n",
"META YTD Gain: 31.31%\n",
"TESLA YTD Gain: -25.49%\n",
"\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
"\n",
"The year-to-date (YTD) gain for META (Meta Platforms, Inc.) is 31.31%, indicating an increase in its stock price since the beginning of the year. On the other hand, TESLA (Tesla, Inc.) has experienced a YTD loss of -25.49%, indicating a decrease in its stock price since the beginning of the year.\n",
"\n",
"These percentages reflect the performance of each company's stock from the start of the year to today's date, 2024-02-07.\n",
"\n",
"TERMINATE\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"# create an AssistantAgent named \"assistant\"\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"assistant = autogen.AssistantAgent(\n",
" name=\"assistant\",\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
" llm_config={\n",
" \"cache_seed\": 41, # seed for caching and reproducibility\n",
" \"config_list\": config_list, # a list of OpenAI API configurations\n",
" \"temperature\": 0, # temperature for sampling\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
" }, # configuration for autogen's enhanced inference API which is compatible with OpenAI API\n",
")\n",
"# create a UserProxyAgent instance named \"user_proxy\"\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"user_proxy = autogen.UserProxyAgent(\n",
" name=\"user_proxy\",\n",
" human_input_mode=\"NEVER\",\n",
" max_consecutive_auto_reply=10,\n",
" is_termination_msg=lambda x: x.get(\"content\", \"\").rstrip().endswith(\"TERMINATE\"),\n",
" code_execution_config={\n",
" \"work_dir\": \"coding\",\n",
" \"use_docker\": False, # Please set use_docker=True if docker is available to run the generated code. Using docker is safer than running the generated code directly.\n",
" },\n",
")\n",
"# the assistant receives a message from the user_proxy, which contains the task description\n",
"chat_res = user_proxy.initiate_chat(\n",
" assistant,\n",
" message=\"\"\"What date is today? Compare the year-to-date gain for META and TESLA.\"\"\",\n",
" summary_method=\"reflection_with_llm\",\n",
")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
2023-09-16 16:34:16 +00:00
"The example above involves code execution. In AutoGen, code execution is triggered automatically by the `UserProxyAgent` when it detects an executable code block in a received message and no human user input is provided. This process occurs in a designated working directory, using a Docker container by default. Unless a specific directory is specified, AutoGen defaults to the `autogen/extensions` directory. Users have the option to specify a different working directory by setting the `work_dir` argument when constructing a new instance of the `UserProxyAgent`.\n",
"\n",
"The whole chat is auto-generated."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Check chat results\n",
"The `initiate_chat` method returns a `ChatResult` object, which is a dataclass object storing information about the chat. Currently, it includes the following attributes:\n",
"\n",
"- `chat_history`: a list of chat history.\n",
"- `summary`: a string of chat summary. A summary is only available if a summary_method is provided when initiating the chat.\n",
"- `cost`: a tuple of (total_cost, total_actual_cost), where total_cost is a dictionary of cost information, and total_actual_cost is a dictionary of information on the actual incurred cost with cache.\n",
"- `human_input`: a list of strings of human inputs solicited during the chat. (Note that since we are setting `human_input_mode` to `NEVER` in this notebook, this list is always empty.)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Chat history: [{'content': 'What date is today? Compare the year-to-date gain for META and TESLA.', 'role': 'assistant'}, {'content': \"To get the current date, we can use Python's `datetime` module. After that, we will need to retrieve the year-to-date (YTD) gain for both META (Meta Platforms, Inc.) and TESLA (Tesla, Inc.). We can do this by fetching the stock prices from the beginning of the year and the current stock prices, then calculating the percentage change.\\n\\nFirst, let's write a Python script to get the current date:\\n\\n```python\\n# filename: get_current_date.py\\n\\nfrom datetime import datetime\\n\\n# Get the current date\\ncurrent_date = datetime.now()\\n\\n# Print the current date in YYYY-MM-DD format\\nprint(current_date.strftime('%Y-%m-%d'))\\n```\\n\\nPlease save the above code in a file named `get_current_date.py` and execute it to get today's date. After that, we will proceed to the next step of fetching the stock data.\", 'role': 'user'}, {'content': 'exitcode: 0 (execution succeeded)\\nCode output: \\n2024-02-07\\n', 'role': 'assistant'}, {'content': 'Great, today\\'s date is 2024-02-07. Now, let\\'s move on to the next step, which is to fetch the stock prices for META and TESLA.\\n\\nWe will use Python to retrieve the stock data. There are several financial data APIs available, but for this example, we\\'ll use `yfinance`, which is a popular library that allows us to fetch historical market data from Yahoo Finance.\\n\\nFirst, we need to install the `yfinance` package. You can do this by running the following command:\\n\\n```sh\\npip install yfinance\\n```\\n\\nAfter installing `yfinance`, we will write a Python script to fetch the YTD stock prices for META and TESLA and calculate the YTD gain. The YTD gain is calculated by comparing the current stock price to the stock price at the beginning of the year.\\n\\nHere\\'s the Python script to do that:\\n\\n```python\\n# filename: ytd_stock_comparison.py\\n\\nimport yfinance as yf\\nfrom datetime import datetime\\n\\n# Define the tickers for Meta Platforms, Inc. and Tesla, Inc.\\ntickers = [\"META\", \"TSLA\"]\\n\\n# Define the start of the year\\nstart_of_year = datetime(datetime.now().year, 1, 1)\\n\\n# Fetch the stock data\\nmeta_data = yf.download(tickers[0], start=start_of_year, end=datetime.now())\\ntesla_data = yf.download(tickers[1], start=start_of_year, end=datetime.now())\\n\\n# Calculate the YTD gain for each stock\\nmeta_ytd_gain = ((meta_data[\\'Close\\'][-1] - meta_data[\\'Close\\'][0]) / meta_data[\\'Close\\'][0]) * 100\\ntesla_ytd_gain = ((tesla_data[\\'Close\\'][-1] - tesla_data[\\'Close\\'][0]) / tesla_data[\\'Close\\'][0]) * 100\\n\\n# Print the YTD gain for each stock\\nprint(f\"META YTD Gain: {meta_ytd_gain:.2f}%\")\\nprint(f\"TESLA YTD Gain: {tesla_ytd_gain:.2f}%\")\\n```\\n\\nPlease save the above code in a file named `ytd_stock_comparison.py` and execute it. This script will output the YTD gain for both META and TESLA stocks.', 'role': 'user'}, {'content': 'exitcode: 0 (execution succeeded)\\nCode output: \\nRequirement already satisfied: yfinance in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (0.2.36)\\nRequirement already satisfied: pandas>=1.3.0 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (2.2.0)\\nRequirement already satisfied: numpy>=1.16.5 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (1.26.3)\\nRequirement already satisfied: requests>=2.31 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (2.31.0)\\nRequirement already satisfied: multitasking>=0.0.7 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (0.0.11)\\nRequirement already satisfied: lxml>=4.9.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (5.1.0)\\nRequirement already satisfied: appdirs>=1.4.4 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (1.4.4)\\nRequirement already satisfied: pytz>=2022.5 in /Users/qi
"Summary: The year-to-date gain for META is 31.31%, while TESLA has a year-to-date loss of -25.49% as of February 7, 2024.\n",
"Cost info: ({'total_cost': 0.20895, 'gpt-4': {'cost': 0.20895, 'prompt_tokens': 5355, 'completion_tokens': 805, 'total_tokens': 6160}}, {'total_cost': 0.18321, 'gpt-4': {'cost': 0.18321, 'prompt_tokens': 4865, 'completion_tokens': 621, 'total_tokens': 5486}})\n"
]
}
],
"source": [
"print(\"Chat history:\", chat_res.chat_history)\n",
"\n",
"print(\"Summary:\", chat_res.summary)\n",
"print(\"Cost info:\", chat_res.cost)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example Task: Plot Chart"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
"\n",
"Plot a chart of their stock price change YTD and save to stock_price_ytd.png.\n",
"\n",
"--------------------------------------------------------------------------------\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
"\n",
"To plot a chart of the YTD stock price changes for META and TESLA and save it to a file named `stock_price_ytd.png`, we will use Python with the `matplotlib` library for plotting and `yfinance` to fetch the stock data.\n",
"\n",
"First, ensure that `matplotlib` is installed by running the following command:\n",
"\n",
"```sh\n",
"pip install matplotlib\n",
"```\n",
"\n",
"Next, here's the Python script to fetch the stock data, plot the chart, and save it:\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\n",
"```python\n",
"# filename: plot_stock_price_ytd.py\n",
"\n",
"import yfinance as yf\n",
"import matplotlib.pyplot as plt\n",
"from datetime import datetime\n",
"\n",
"# Define the tickers for Meta Platforms, Inc. and Tesla, Inc.\n",
"tickers = [\"META\", \"TSLA\"]\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\n",
"# Define the start of the year\n",
"start_of_year = datetime(datetime.now().year, 1, 1)\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\n",
"# Fetch the stock data\n",
"meta_data = yf.download(tickers[0], start=start_of_year, end=datetime.now())\n",
"tesla_data = yf.download(tickers[1], start=start_of_year, end=datetime.now())\n",
"\n",
"# Normalize the data to compare the percentage change\n",
"meta_normalized = (meta_data['Close'] / meta_data['Close'].iloc[0]) * 100\n",
"tesla_normalized = (tesla_data['Close'] / tesla_data['Close'].iloc[0]) * 100\n",
"\n",
"# Plot the data\n",
"plt.figure(figsize=(14, 7))\n",
"plt.plot(meta_normalized, label='META YTD')\n",
"plt.plot(tesla_normalized, label='TESLA YTD')\n",
"\n",
"# Add titles and labels\n",
"plt.title('YTD Stock Price Change for META and TESLA')\n",
"plt.xlabel('Date')\n",
"plt.ylabel('Normalized Price (Base 100)')\n",
"plt.legend()\n",
"\n",
"# Save the plot to a file\n",
"plt.savefig('stock_price_ytd.png')\n",
"plt.show()\n",
"```\n",
"\n",
"Please save the above code in a file named `plot_stock_price_ytd.py` and execute it. This script will create a chart showing the normalized YTD stock price changes for META and TESLA, and save the chart as `stock_price_ytd.png`. The normalization sets the initial stock prices to 100 to compare the relative changes in stock prices over time.\n",
"\n",
"--------------------------------------------------------------------------------\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\u001b[31m\n",
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is sh)...\u001b[0m\n",
"\u001b[31m\n",
">>>>>>>> EXECUTING CODE BLOCK 1 (inferred language is python)...\u001b[0m\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
"\n",
"exitcode: 0 (execution succeeded)\n",
"Code output: \n",
"Requirement already satisfied: matplotlib in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (3.8.2)\n",
"Requirement already satisfied: contourpy>=1.0.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from matplotlib) (1.2.0)\n",
"Requirement already satisfied: cycler>=0.10 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from matplotlib) (0.12.1)\n",
"Requirement already satisfied: fonttools>=4.22.0 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from matplotlib) (4.47.2)\n",
"Requirement already satisfied: kiwisolver>=1.3.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from matplotlib) (1.4.5)\n",
"Requirement already satisfied: numpy<2,>=1.21 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from matplotlib) (1.26.3)\n",
"Requirement already satisfied: packaging>=20.0 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from matplotlib) (23.2)\n",
"Requirement already satisfied: pillow>=8 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from matplotlib) (10.2.0)\n",
"Requirement already satisfied: pyparsing>=2.3.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from matplotlib) (3.1.1)\n",
"Requirement already satisfied: python-dateutil>=2.7 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from matplotlib) (2.8.2)\n",
"Requirement already satisfied: six>=1.5 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)\n",
"\n",
"Figure(1400x700)\n",
"\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
"\n",
"The chart showing the year-to-date (YTD) stock price changes for META and TESLA has been successfully created and saved as `stock_price_ytd.png`. The chart should now be available in the directory where the script was executed.\n",
"\n",
"TERMINATE\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"# followup of the previous question\n",
"chat_res = user_proxy.send(\n",
" recipient=assistant,\n",
" message=\"\"\"Plot a chart of their stock price change YTD and save to stock_price_ytd.png.\"\"\",\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Chat history: [{'content': 'What date is today? Compare the year-to-date gain for META and TESLA.', 'role': 'assistant'}, {'content': \"To get the current date, we can use Python's `datetime` module. After that, we will need to retrieve the year-to-date (YTD) gain for both META (Meta Platforms, Inc.) and TESLA (Tesla, Inc.). We can do this by fetching the stock prices from the beginning of the year and the current stock prices, then calculating the percentage change.\\n\\nFirst, let's write a Python script to get the current date:\\n\\n```python\\n# filename: get_current_date.py\\n\\nfrom datetime import datetime\\n\\n# Get the current date\\ncurrent_date = datetime.now()\\n\\n# Print the current date in YYYY-MM-DD format\\nprint(current_date.strftime('%Y-%m-%d'))\\n```\\n\\nPlease save the above code in a file named `get_current_date.py` and execute it to get today's date. After that, we will proceed to the next step of fetching the stock data.\", 'role': 'user'}, {'content': 'exitcode: 0 (execution succeeded)\\nCode output: \\n2024-02-05\\n', 'role': 'assistant'}, {'content': 'Great, today\\'s date is 2024-02-05. Now, let\\'s proceed to fetch the stock data for META and TESLA to compare their year-to-date gains.\\n\\nWe will use Python to fetch the stock data. For this purpose, we can use the `yfinance` library, which allows us to retrieve historical market data from Yahoo Finance. If `yfinance` is not installed, you will need to install it using `pip install yfinance`.\\n\\nHere\\'s the Python script to fetch the YTD stock data for META and TESLA and calculate their gains:\\n\\n```python\\n# filename: compare_ytd_gains.py\\n\\nimport yfinance as yf\\nfrom datetime import datetime\\n\\n# Define the tickers for Meta Platforms, Inc. and Tesla, Inc.\\ntickers = [\"META\", \"TSLA\"]\\n\\n# Define the start of the year\\nstart_of_year = datetime(datetime.now().year, 1, 1)\\n\\n# Fetch the historical data from the start of the year to the current date\\nmeta_data = yf.download(tickers[0], start=start_of_year, end=datetime.now())\\ntesla_data = yf.download(tickers[1], start=start_of_year, end=datetime.now())\\n\\n# Calculate the YTD gain for each stock\\nmeta_ytd_gain = ((meta_data[\\'Close\\'][-1] - meta_data[\\'Close\\'][0]) / meta_data[\\'Close\\'][0]) * 100\\ntesla_ytd_gain = ((tesla_data[\\'Close\\'][-1] - tesla_data[\\'Close\\'][0]) / tesla_data[\\'Close\\'][0]) * 100\\n\\n# Print the YTD gains\\nprint(f\"META YTD Gain: {meta_ytd_gain:.2f}%\")\\nprint(f\"TESLA YTD Gain: {tesla_ytd_gain:.2f}%\")\\n\\n# Compare the YTD gains\\nif meta_ytd_gain > tesla_ytd_gain:\\n print(\"META has a higher YTD gain than TESLA.\")\\nelif meta_ytd_gain < tesla_ytd_gain:\\n print(\"TESLA has a higher YTD gain than META.\")\\nelse:\\n print(\"META and TESLA have the same YTD gain.\")\\n```\\n\\nPlease save the above code in a file named `compare_ytd_gains.py` and execute it. The script will output the YTD gains for both META and TESLA and indicate which one is higher.', 'role': 'user'}, {'content': 'exitcode: 0 (execution succeeded)\\nCode output: \\nMETA YTD Gain: 37.17%\\nTESLA YTD Gain: -24.36%\\nMETA has a higher YTD gain than TESLA.\\n', 'role': 'assistant'}, {'content': 'The year-to-date (YTD) gain for META (Meta Platforms, Inc.) is 37.17%, while the YTD gain for TESLA (Tesla, Inc.) is -24.36%. This means that so far this year, META has had a higher gain compared to TESLA.\\n\\nIf you need further assistance or have more questions, feel free to ask. Otherwise, if everything is done, please let me know.\\n\\nTERMINATE', 'role': 'user'}, {'content': 'Plot a chart of their stock price change YTD and save to stock_price_ytd.png.', 'role': 'assistant'}, {'content': 'To plot a chart of the stock price changes YTD for META and TESLA and save it to a file named `stock_price_ytd.png`, we will use Python with the `matplotlib` library for plotting and `yfinance` to fetch the stock data.\\n\\nIf `matplotlib` is not installed, you will need to install it using `pip install matplotlib`.\\n\\nHere\\'s the Python script to plot the cha
"Summary: None\n",
"Cost info: ({'total_cost': 0.28146, 'gpt-4': {'cost': 0.28146, 'prompt_tokens': 6642, 'completion_tokens': 1370, 'total_tokens': 8012}}, {'total_cost': 0})\n"
]
}
],
"source": [
"print(\"Chat history:\", chat_res.chat_history)\n",
"print(\"Summary:\", chat_res.summary)\n",
"print(\"Cost info:\", chat_res.cost)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's display the generated figure."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABXgAAAK8CAYAAABV1dcbAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8g+/7EAAAACXBIWXMAAA9hAAAPYQGoP6dpAACtu0lEQVR4nOzdd3gU5frG8XvTE0IaLYTee1FApAlI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jyoQYMGKSgoSIGBgRo8eLDi4uLSHZuQkKBnnnlGJUqUUNGiRXX33Xdnu578cOjQITVp0iTTsP7q99OcmjVrloKDg9W1a1f17t1bs2bNupkyAQBAIcEMXgAAkCcqVKigdevWaefOnddduOvrr7/WQw89pNtuu03Dhw+XJFWpUkWStGvXLrVq1UoBAQF6/vnn5enpqSlTpqhNmzb6448/7D0jY2Nj1apVK+3Zs0dDhgzRrbfeqrNnz+rHH3/U8ePHM51lePnyZd1zzz3atGmTfv/9dzVp0iTH13jo0CFJUrFixdKNP/bYYypRooReffVVXbp0KcvnT58+XUOGDFGdOnU0atQoBQUF6e+//9aSJUvsX7levny5OnfurEaNGmn06NFyc3PTtGnTdOedd2r16tW67bbbsjz/jz/+KEk56uV6/vx5derUST179lTfvn01b948vfDCC6pXr546d+4syezp+8UXX+i+++7TsGHDdPHiRU2dOlUdO3bUX3/9laFdxezZs3Xx4kU9/PDDstlseu+999SzZ0/9888/8vT0lCT9/PPPuvfee1WvXj2
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"try:\n",
" image = Image(filename=\"coding/stock_price_ytd.png\")\n",
" display(image)\n",
"except FileNotFoundError:\n",
" print(\"Image not found. Please check the file name and modify if necessary.\")"
]
},
{
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Use a Different Code Execution Environment\n",
"\n",
"The code execution happened in a separate process, so the plot is not directly displayed in the notebook. Is it possible to change the code execution environment into IPython?\n",
"\n",
"Yes! In the following we demonstrate how to extend the `UserProxyAgent` to use a different code execution environment."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"class IPythonUserProxyAgent(autogen.UserProxyAgent):\n",
" def __init__(self, name: str, **kwargs):\n",
" super().__init__(name, **kwargs)\n",
" self._ipython = get_ipython()\n",
"\n",
" def generate_init_message(self, *args, **kwargs) -> Union[str, Dict]:\n",
" return (\n",
" super().generate_init_message(*args, **kwargs)\n",
" + \"\"\"\n",
"If you suggest code, the code will be executed in IPython.\"\"\"\n",
" )\n",
"\n",
" def run_code(self, code, **kwargs):\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
" result = self._ipython.run_cell(\"%%capture --no-display cap\\n\" + code)\n",
" log = self._ipython.ev(\"cap.stdout\")\n",
" log += self._ipython.ev(\"cap.stderr\")\n",
" if result.result is not None:\n",
" log += str(result.result)\n",
" exitcode = 0 if result.success else 1\n",
" if result.error_before_exec is not None:\n",
" log += f\"\\n{result.error_before_exec}\"\n",
" exitcode = 1\n",
" if result.error_in_exec is not None:\n",
" log += f\"\\n{result.error_in_exec}\"\n",
" exitcode = 1\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
" return exitcode, log, None"
]
},
{
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"The implementation overrides three functions in `UserProxyAgent`:\n",
"* constructor. We get the ipython instance as the code execution environment.\n",
"* `generate_init_message`. We generate a modified initial message to send to the assistant agent, by adding the info that the execution will be performed in IPython.\n",
"* `run_code`. We execute the code with the ipython instance.\n",
"\n",
"With the new `IPythonUserProxyAgent`, we are able to run the code within the current notebook environment and display the plot directly."
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\u001b[33mipython_user_proxy\u001b[0m (to assistant):\n",
"\n",
"Plot a chart of META and TESLA stock price gain YTD\n",
"If you suggest code, the code will be executed in IPython.\n",
"\n",
"--------------------------------------------------------------------------------\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\u001b[33massistant\u001b[0m (to ipython_user_proxy):\n",
"\n",
"To plot a chart of META (Facebook's parent company, Meta Platforms, Inc.) and TESLA (Tesla, Inc.) stock price gain year-to-date (YTD), we can use Python with libraries such as `pandas` for data manipulation and `matplotlib` or `plotly` for plotting. We will also use `yfinance` to fetch historical stock data.\n",
"\n",
"Here's the plan:\n",
"1. Install the `yfinance` library if it's not already installed.\n",
"2. Fetch the YTD stock price data for META and TESLA.\n",
"3. Calculate the YTD gain for each stock.\n",
"4. Plot the YTD gain on a chart.\n",
"\n",
"First, let's install `yfinance` and import the necessary libraries. Execute the following code:\n",
"\n",
"```python\n",
"# Install yfinance if not already installed\n",
"!pip install yfinance\n",
"\n",
"import yfinance as yf\n",
"import pandas as pd\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"import matplotlib.pyplot as plt\n",
"from datetime import datetime\n",
"\n",
"# Check if today's date is required or the last trading day\n",
"today = datetime.today().strftime('%Y-%m-%d')\n",
"\n",
"# Fetch YTD stock data for META and TESLA\n",
"meta_data = yf.download('META', start='2023-01-01', end=today)\n",
"tesla_data = yf.download('TSLA', start='2023-01-01', end=today)\n",
"\n",
"# Calculate the YTD gain for each stock\n",
"meta_ytd_gain = (meta_data['Close'] - meta_data['Close'].iloc[0]) / meta_data['Close'].iloc[0] * 100\n",
"tesla_ytd_gain = (tesla_data['Close'] - tesla_data['Close'].iloc[0]) / tesla_data['Close'].iloc[0] * 100\n",
"\n",
"# Plot the YTD gain on a chart\n",
"plt.figure(figsize=(14, 7))\n",
"plt.plot(meta_ytd_gain.index, meta_ytd_gain, label='META YTD Gain %')\n",
"plt.plot(tesla_ytd_gain.index, tesla_ytd_gain, label='TESLA YTD Gain %')\n",
"plt.title('META vs TESLA Stock Price Gain YTD')\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"plt.xlabel('Date')\n",
"plt.ylabel('Gain %')\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"plt.legend()\n",
"plt.grid(True)\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"plt.show()\n",
"```\n",
"\n",
"This code will install `yfinance`, fetch the YTD stock data for META and TESLA, calculate the YTD gain, and plot it on a chart. Please execute the code in your IPython environment.\n",
"\n",
"--------------------------------------------------------------------------------\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\u001b[31m\n",
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABIgAAAJwCAYAAADiPVqNAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8g+/7EAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd1yVdf/H8dc57CkCMhRUcCHulStNzT0aVmZDs2FDu1s27sbdrVl53/3aw1IzbWjZULu1NFdp7m25FXGgIgoCCgKHc67fHweOIltBFN7Px4MH51zze11eEOfT5/P5mgzDMBARERERERERkSrLXNEDEBERERERER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P/+/fnG8dFHHxU61gv9+OOPBmD4+/sbkZGRBY4n16WWmOWaM2eOARgffPBBicYmIiJyMWUQiYiIFGPIkCGcO3eO+fPnc+bMGebPn19sednNN9/M4sWL830VloFRlBkzZjBgwABHWU2DBg1o06ZNiUqkevToQWBgILNmzXIsO336NIsXL+bOO+90LPPz8yMuLq5EGTWXo3379gXel9zsKIAHHniAhQsX0q1bN1auXMn48ePp0qULDRo0YPXq1Zd03hkzZhAcHOy4/yaTiTvvvJPvvvsOq9Va7P7Tpk3j448/JiIigjlz5vDss8/SuHFjbrzxRo4ePVrs/kuWLCErK4unnnoqT3nRyJEj8fX15ZdffgFgy5YtxMbG8tRTT+H
"text/plain": [
"<Figure size 1400x700 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"\u001b[33mipython_user_proxy\u001b[0m (to assistant):\n",
"\n",
"exitcode: 0 (execution succeeded)\n",
"Code output: \n",
"Requirement already satisfied: yfinance in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (0.2.36)\n",
"Requirement already satisfied: pandas>=1.3.0 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (2.2.0)\n",
"Requirement already satisfied: numpy>=1.16.5 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (1.26.3)\n",
"Requirement already satisfied: requests>=2.31 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (2.31.0)\n",
"Requirement already satisfied: multitasking>=0.0.7 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (0.0.11)\n",
"Requirement already satisfied: lxml>=4.9.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (5.1.0)\n",
"Requirement already satisfied: appdirs>=1.4.4 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (1.4.4)\n",
"Requirement already satisfied: pytz>=2022.5 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (2023.3.post1)\n",
"Requirement already satisfied: frozendict>=2.3.4 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (2.4.0)\n",
"Requirement already satisfied: peewee>=3.16.2 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (3.17.0)\n",
"Requirement already satisfied: beautifulsoup4>=4.11.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (4.12.3)\n",
"Requirement already satisfied: html5lib>=1.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (1.1)\n",
"Requirement already satisfied: soupsieve>1.2 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from beautifulsoup4>=4.11.1->yfinance) (2.5)\n",
"Requirement already satisfied: six>=1.9 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from html5lib>=1.1->yfinance) (1.16.0)\n",
"Requirement already satisfied: webencodings in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from html5lib>=1.1->yfinance) (0.5.1)\n",
"Requirement already satisfied: python-dateutil>=2.8.2 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from pandas>=1.3.0->yfinance) (2.8.2)\n",
"Requirement already satisfied: tzdata>=2022.7 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from pandas>=1.3.0->yfinance) (2023.4)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from requests>=2.31->yfinance) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from requests>=2.31->yfinance) (3.6)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from requests>=2.31->yfinance) (2.1.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from requests>=2.31->yfinance) (2023.11.17)\n",
"/Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages/yfinance/utils.py:775: FutureWarning: The 'unit' keyword in TimedeltaIndex construction is deprecated and will be removed in a future version. Use pd.to_timedelta instead.\n",
" df.index += _pd.TimedeltaIndex(dst_error_hours, 'h')\n",
"[*********************100%%**********************] 1 of 1 completed\n",
"/Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages/yfinance/utils.py:775: FutureWarning: The 'unit' keyword in TimedeltaIndex construction is deprecated and will be removed in a future version. Use pd.to_timedelta instead.\n",
" df.index += _pd.TimedeltaIndex(dst_error_hours, 'h')\n",
"[*********************100%%**********************] 1 of 1 completed\n",
"\n",
"\n",
raise error when msg is invalid; fix docstr; improve ResponsiveAgent; update doc and packaging; capture ipython output; find code blocks with llm when regex fails. (#1154) * autogen.agent -> autogen.agentchat * bug fix in portfolio * notebook * timeout * timeout * infer lang; close #1150 * timeout * message context * context handling * add sender to generate_reply * clean up the receive function * move mathchat to contrib * contrib * last_message * Add OptiGuide: agent and notebook * Optiguide notebook: add figures and URL 1. figures and code points to remote URL 2. simplify the prompt for the interpreter, because all information is already in the chat history. * Update name: Agent -> GenericAgent * Update notebook * Rename: GenericAgent -> ResponsiveAgent * Rebase to autogen.agentchat * OptiGuide: Comment, sytle, and notebook updates * simplify optiguide * raise error when msg is invalid; fix docstr * allow return None for generate_reply() * update_system_message * test update_system_message * simplify optiguide * simplify optiguide * simplify optiguide * simplify optiguide * move test * add test and fix bug * doc update * doc update * doc update * color * optiguide * prompt * test danger case * packaging * docker * remove path in traceback * capture ipython output * simplify * find code blocks with llm * find code with llm * order * order * fix bug in context handling * print executing msg * print executing msg * test find code * test find code * disable find_code * default_auto_reply * default auto reply * remove optiguide * remove -e --------- Co-authored-by: Beibin Li <beibin79@gmail.com>
2023-07-31 19:22:30 -07:00
"--------------------------------------------------------------------------------\n",
"\u001b[33massistant\u001b[0m (to ipython_user_proxy):\n",
"\n",
"The code has executed successfully, and the required libraries are already installed on your system. The warning from `yfinance` about the 'unit' keyword in `TimedeltaIndex` construction is a future deprecation notice and does not affect the execution of the current code.\n",
"\n",
"Since the code has been executed without any errors, you should have seen a plot displaying the YTD gain percentage for both META and TESLA stocks. This plot visually compares the performance of the two stocks since the beginning of the year.\n",
"\n",
"If you have seen the plot and it reflects the YTD gains for both stocks, then the task is complete. If the plot did not display or if there were any issues with the visualization, please let me know so I can assist further.\n",
"\n",
"If everything is in order, this concludes the task.\n",
"\n",
"TERMINATE\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/qingyunwu/Documents/github/autogen/autogen/agentchat/conversable_agent.py:793: UserWarning: No summary_method provided or summary_method is not supported: \n",
" cache=cache,\n"
]
},
{
"data": {
"text/plain": [
"ChatResult(chat_history=[{'content': 'Plot a chart of META and TESLA stock price gain YTD\\nIf you suggest code, the code will be executed in IPython.', 'role': 'assistant'}, {'content': \"To plot a chart of META (Facebook's parent company, Meta Platforms, Inc.) and TESLA (Tesla, Inc.) stock price gain year-to-date (YTD), we can use Python with libraries such as `pandas` for data manipulation and `matplotlib` or `plotly` for plotting. We will also use `yfinance` to fetch historical stock data.\\n\\nHere's the plan:\\n1. Install the `yfinance` library if it's not already installed.\\n2. Fetch the YTD stock price data for META and TESLA.\\n3. Calculate the YTD gain for each stock.\\n4. Plot the YTD gain on a chart.\\n\\nFirst, let's install `yfinance` and import the necessary libraries. Execute the following code:\\n\\n```python\\n# Install yfinance if not already installed\\n!pip install yfinance\\n\\nimport yfinance as yf\\nimport pandas as pd\\nimport matplotlib.pyplot as plt\\nfrom datetime import datetime\\n\\n# Check if today's date is required or the last trading day\\ntoday = datetime.today().strftime('%Y-%m-%d')\\n\\n# Fetch YTD stock data for META and TESLA\\nmeta_data = yf.download('META', start='2023-01-01', end=today)\\ntesla_data = yf.download('TSLA', start='2023-01-01', end=today)\\n\\n# Calculate the YTD gain for each stock\\nmeta_ytd_gain = (meta_data['Close'] - meta_data['Close'].iloc[0]) / meta_data['Close'].iloc[0] * 100\\ntesla_ytd_gain = (tesla_data['Close'] - tesla_data['Close'].iloc[0]) / tesla_data['Close'].iloc[0] * 100\\n\\n# Plot the YTD gain on a chart\\nplt.figure(figsize=(14, 7))\\nplt.plot(meta_ytd_gain.index, meta_ytd_gain, label='META YTD Gain %')\\nplt.plot(tesla_ytd_gain.index, tesla_ytd_gain, label='TESLA YTD Gain %')\\nplt.title('META vs TESLA Stock Price Gain YTD')\\nplt.xlabel('Date')\\nplt.ylabel('Gain %')\\nplt.legend()\\nplt.grid(True)\\nplt.show()\\n```\\n\\nThis code will install `yfinance`, fetch the YTD stock data for META and TESLA, calculate the YTD gain, and plot it on a chart. Please execute the code in your IPython environment.\", 'role': 'user'}, {'content': \"exitcode: 0 (execution succeeded)\\nCode output: \\nRequirement already satisfied: yfinance in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (0.2.36)\\r\\nRequirement already satisfied: pandas>=1.3.0 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (2.2.0)\\r\\nRequirement already satisfied: numpy>=1.16.5 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (1.26.3)\\r\\nRequirement already satisfied: requests>=2.31 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (2.31.0)\\r\\nRequirement already satisfied: multitasking>=0.0.7 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (0.0.11)\\r\\nRequirement already satisfied: lxml>=4.9.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (5.1.0)\\r\\nRequirement already satisfied: appdirs>=1.4.4 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (1.4.4)\\r\\nRequirement already satisfied: pytz>=2022.5 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (2023.3.post1)\\r\\nRequirement already satisfied: frozendict>=2.3.4 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (2.4.0)\\r\\nRequirement already satisfied: peewee>=3.16.2 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (3.17.0)\\r\\nRequirement already satisfied: beautifulsoup4>=4.11.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (4.12.3)\\r\\nRequirement already satisfied: html5lib>=1.1 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from yfinance) (1.1)\\r\\nRequirement already satisfied: soupsieve>1.2 in /Users/qingyunwu/miniconda3/envs/ag2/lib/python3.10/site-packages (from beautifulsoup4>=4.11.1->yfinance) (2.5)\\r
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ipy_user = IPythonUserProxyAgent(\n",
" \"ipython_user_proxy\",\n",
" human_input_mode=\"NEVER\",\n",
" max_consecutive_auto_reply=10,\n",
" is_termination_msg=lambda x: x.get(\"content\", \"\").rstrip().endswith(\"TERMINATE\")\n",
" or x.get(\"content\", \"\").rstrip().endswith('\"TERMINATE\".'),\n",
" code_execution_config={\n",
" \"use_docker\": False, # Please set use_docker=True if docker is available to run the generated code. Using docker is safer than running the generated code directly.\n",
" },\n",
")\n",
"# the assistant receives a message from the user, which contains the task description\n",
"ipy_user.initiate_chat(\n",
" assistant,\n",
" message=\"\"\"Plot a chart of META and TESLA stock price gain YTD\"\"\",\n",
")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
},
"vscode": {
"interpreter": {
"hash": "949777d72b0d2535278d3dc13498b2535136f6dfe0678499012e853ee9abcab1"
}
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {
"2d910cfd2d2a4fc49fc30fbbdc5576a7": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "2.0.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "2.0.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border_bottom": null,
"border_left": null,
"border_right": null,
"border_top": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"454146d0f7224f038689031002906e6f": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HBoxModel",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "2.0.0",
"_model_name": "HBoxModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "2.0.0",
"_view_name": "HBoxView",
"box_style": "",
"children": [
"IPY_MODEL_e4ae2b6f5a974fd4bafb6abb9d12ff26",
"IPY_MODEL_577e1e3cc4db4942b0883577b3b52755",
"IPY_MODEL_b40bdfb1ac1d4cffb7cefcb870c64d45"
],
"layout": "IPY_MODEL_dc83c7bff2f241309537a8119dfc7555",
"tabbable": null,
"tooltip": null
}
},
"577e1e3cc4db4942b0883577b3b52755": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "FloatProgressModel",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "2.0.0",
"_model_name": "FloatProgressModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "2.0.0",
"_view_name": "ProgressView",
"bar_style": "success",
"description": "",
"description_allow_html": false,
"layout": "IPY_MODEL_2d910cfd2d2a4fc49fc30fbbdc5576a7",
"max": 1,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_74a6ba0c3cbc4051be0a83e152fe1e62",
"tabbable": null,
"tooltip": null,
"value": 1
}
},
"6086462a12d54bafa59d3c4566f06cb2": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "2.0.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "2.0.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border_bottom": null,
"border_left": null,
"border_right": null,
"border_top": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"74a6ba0c3cbc4051be0a83e152fe1e62": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "ProgressStyleModel",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "2.0.0",
"_model_name": "ProgressStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "2.0.0",
"_view_name": "StyleView",
"bar_color": null,
"description_width": ""
}
},
"7d3f3d9e15894d05a4d188ff4f466554": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLStyleModel",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "2.0.0",
"_model_name": "HTMLStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "2.0.0",
"_view_name": "StyleView",
"background": null,
"description_width": "",
"font_size": null,
"text_color": null
}
},
"b40bdfb1ac1d4cffb7cefcb870c64d45": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLModel",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "2.0.0",
"_model_name": "HTMLModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "2.0.0",
"_view_name": "HTMLView",
"description": "",
"description_allow_html": false,
"layout": "IPY_MODEL_f1355871cc6f4dd4b50d9df5af20e5c8",
"placeholder": "",
"style": "IPY_MODEL_ca245376fd9f4354af6b2befe4af4466",
"tabbable": null,
"tooltip": null,
"value": " 1/1 [00:00&lt;00:00, 44.69it/s]"
}
},
"ca245376fd9f4354af6b2befe4af4466": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLStyleModel",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "2.0.0",
"_model_name": "HTMLStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "2.0.0",
"_view_name": "StyleView",
"background": null,
"description_width": "",
"font_size": null,
"text_color": null
}
},
"dc83c7bff2f241309537a8119dfc7555": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "2.0.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "2.0.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border_bottom": null,
"border_left": null,
"border_right": null,
"border_top": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"e4ae2b6f5a974fd4bafb6abb9d12ff26": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLModel",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "2.0.0",
"_model_name": "HTMLModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "2.0.0",
"_view_name": "HTMLView",
"description": "",
"description_allow_html": false,
"layout": "IPY_MODEL_6086462a12d54bafa59d3c4566f06cb2",
"placeholder": "",
"style": "IPY_MODEL_7d3f3d9e15894d05a4d188ff4f466554",
"tabbable": null,
"tooltip": null,
"value": "100%"
}
},
"f1355871cc6f4dd4b50d9df5af20e5c8": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "2.0.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "2.0.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border_bottom": null,
"border_left": null,
"border_right": null,
"border_top": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
}
},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}