2023-07-28 21:17:51 -07:00
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"<a href=\"https://colab.research.google.com/github/microsoft/FLAML/blob/main/notebook/autogen_agentchat_auto_feedback_from_code_execution.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Auto Generated Agent Chat: Task Solving with Code Generation, Execution & Debugging\n",
"\n",
2023-08-14 00:09:45 -07:00
"`flaml.autogen` offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framwork allows tool use and human participance through multi-agent conversation.\n",
"Please find documentation about this feature [here](https://microsoft.github.io/FLAML/docs/Use-Cases/Autogen#agents).\n",
2023-07-28 21:17:51 -07:00
"\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",
"## Requirements\n",
"\n",
"FLAML requires `Python>=3.8`. To run this notebook example, please install flaml with the [autogen] option:\n",
"```bash\n",
"pip install flaml[autogen]\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"execution": {
"iopub.execute_input": "2023-02-13T23:40:52.317406Z",
"iopub.status.busy": "2023-02-13T23:40:52.316561Z",
"iopub.status.idle": "2023-02-13T23:40:52.321193Z",
"shell.execute_reply": "2023-02-13T23:40:52.320628Z"
}
},
"outputs": [],
"source": [
2023-08-14 00:09:45 -07:00
"# %pip install flaml[autogen]~=2.0.0"
2023-07-28 21:17:51 -07:00
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set your API Endpoint\n",
"\n",
"The [`config_list_from_json`](https://microsoft.github.io/FLAML/docs/reference/autogen/oai/openai_utils#config_list_from_json) function loads a list of configurations from an environment variable or a json file.\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
2023-07-31 19:22:30 -07:00
"from flaml import autogen\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"config_list = autogen.config_list_from_json(\n",
2023-07-28 21:17:51 -07:00
" \"OAI_CONFIG_LIST\",\n",
" filter_dict={\n",
2023-08-14 00:09:45 -07:00
" \"model\": [\"gpt-4\", \"gpt4\", \"gpt-4-32k\", \"gpt-4-32k-0314\", \"gpt-4-32k-v0314\"],\n",
2023-07-28 21:17:51 -07:00
" },\n",
")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"It first looks for environment variable \"OAI_CONFIG_LIST\" which needs to be a valid json string. If that variable is not found, it then looks for a json file named \"OAI_CONFIG_LIST\". It filters the configs by models (you can filter by other keys as well). Only the gpt-4 models are kept in the list based on the filter condition.\n",
"\n",
"The config list looks like the following:\n",
"```python\n",
"config_list = [\n",
" {\n",
" 'model': 'gpt-4',\n",
" 'api_key': '<your OpenAI API key here>',\n",
" },\n",
" {\n",
" 'model': 'gpt-4',\n",
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'api_base': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" },\n",
" {\n",
" 'model': 'gpt-4-32k',\n",
" 'api_key': '<your Azure OpenAI API key here>',\n",
" 'api_base': '<your Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-06-01-preview',\n",
" },\n",
"]\n",
"```\n",
"\n",
"If you open this notebook in colab, you can upload your files by clicking the file icon on the left panel and then choose \"upload file\" icon.\n",
"\n",
"You can set the value of config_list in other ways you prefer, e.g., loading from a YAML file."
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example Task: Check Stock Price Change\n",
"\n",
"In the example below, let's see how to use the agents in FLAML 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": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-07-31 19:22:30 -07:00
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
2023-07-28 21:17:51 -07:00
"\n",
"What date is today? Compare the year-to-date gain for META and TESLA.\n",
"\n",
"--------------------------------------------------------------------------------\n",
2023-07-31 19:22:30 -07:00
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
"\n",
"To get the current date and compare the year-to-date gain for META (Facebook) and TESLA, we'll need to fetch stock data. We can use the `yfinance` library for this purpose. First, you'll need to install the library by running the following command:\n",
"\n",
"```sh\n",
"pip install yfinance\n",
"```\n",
"\n",
"After installing the library, execute the following Python code to get the current date and compare the year-to-date gain for META and TESLA:\n",
2023-07-28 21:17:51 -07:00
"\n",
"```python\n",
"import yfinance as yf\n",
2023-07-31 19:22:30 -07:00
"from datetime import datetime, timedelta\n",
2023-07-28 21:17:51 -07:00
"\n",
"# Get today's date\n",
2023-07-31 19:22:30 -07:00
"today = datetime.now()\n",
"print(f\"Today's date is: {today.strftime('%Y-%m-%d')}\")\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"# Calculate the start date for year-to-date\n",
"start_date = datetime(today.year, 1, 1)\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"# Fetch stock data for META (Facebook) and TESLA\n",
"meta = yf.Ticker(\"FB\")\n",
"tesla = yf.Ticker(\"TSLA\")\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"# Get historical stock data\n",
"meta_history = meta.history(start=start_date, end=today)\n",
"tesla_history = tesla.history(start=start_date, end=today)\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"# Calculate year-to-date gain\n",
"meta_ytd_gain = (meta_history[\"Close\"][-1] - meta_history[\"Close\"][0]) / meta_history[\"Close\"][0] * 100\n",
"tesla_ytd_gain = (tesla_history[\"Close\"][-1] - tesla_history[\"Close\"][0]) / tesla_history[\"Close\"][0] * 100\n",
"\n",
"# Print the results\n",
"print(f\"META year-to-date gain: {meta_ytd_gain:.2f}%\")\n",
"print(f\"TESLA year-to-date gain: {tesla_ytd_gain:.2f}%\")\n",
2023-07-28 21:17:51 -07:00
"```\n",
"\n",
2023-07-31 19:22:30 -07:00
"--------------------------------------------------------------------------------\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: 1 (execution failed)\n",
"Code output: \n",
"Defaulting to user installation because normal site-packages is not writeable\n",
"Requirement already satisfied: yfinance in /home/vscode/.local/lib/python3.9/site-packages (0.2.26)\n",
"Requirement already satisfied: lxml>=4.9.1 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (4.9.3)\n",
"Requirement already satisfied: requests>=2.31 in /usr/local/lib/python3.9/site-packages (from yfinance) (2.31.0)\n",
"Requirement already satisfied: multitasking>=0.0.7 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (0.0.11)\n",
"Requirement already satisfied: appdirs>=1.4.4 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (1.4.4)\n",
"Requirement already satisfied: html5lib>=1.1 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (1.1)\n",
"Requirement already satisfied: numpy>=1.16.5 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (1.25.1)\n",
"Requirement already satisfied: pandas>=1.3.0 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (1.3.3)\n",
"Requirement already satisfied: frozendict>=2.3.4 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (2.3.8)\n",
"Requirement already satisfied: beautifulsoup4>=4.11.1 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (4.12.2)\n",
"Requirement already satisfied: pytz>=2022.5 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (2023.3)\n",
"Requirement already satisfied: soupsieve>1.2 in /home/vscode/.local/lib/python3.9/site-packages (from beautifulsoup4>=4.11.1->yfinance) (2.4.1)\n",
"Requirement already satisfied: webencodings in /home/vscode/.local/lib/python3.9/site-packages (from html5lib>=1.1->yfinance) (0.5.1)\n",
"Requirement already satisfied: six>=1.9 in /usr/local/lib/python3.9/site-packages (from html5lib>=1.1->yfinance) (1.16.0)\n",
"Requirement already satisfied: python-dateutil>=2.7.3 in /home/vscode/.local/lib/python3.9/site-packages (from pandas>=1.3.0->yfinance) (2.8.2)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.9/site-packages (from requests>=2.31->yfinance) (2.0.3)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.9/site-packages (from requests>=2.31->yfinance) (3.2.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.9/site-packages (from requests>=2.31->yfinance) (2023.5.7)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.9/site-packages (from requests>=2.31->yfinance) (3.4)\n",
"\n",
"FB: No timezone found, symbol may be delisted\n",
"Traceback (most recent call last):\n",
" File \"\", line 20, in <module>\n",
" meta_ytd_gain = (meta_history[\"Close\"][-1] - meta_history[\"Close\"][0]) / meta_history[\"Close\"][0] * 100\n",
" File \"/home/vscode/.local/lib/python3.9/site-packages/pandas/core/series.py\", line 939, in __getitem__\n",
" return self._values[key]\n",
"IndexError: index -1 is out of bounds for axis 0 with size 0\n",
"\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
"\n",
"I apologize for the error. It seems that the stock symbol for Meta Platforms (formerly Facebook) has changed to \"META\" instead of \"FB\". Let's update the code with the correct stock symbol and try again:\n",
"\n",
"```python\n",
"import yfinance as yf\n",
"from datetime import datetime, timedelta\n",
"\n",
"# Get today's date\n",
"today = datetime.now()\n",
"print(f\"Today's date is: {today.strftime('%Y-%m-%d')}\")\n",
"\n",
"# Calculate the start date for year-to-date\n",
"start_date = datetime(today.year, 1, 1)\n",
"\n",
"# Fetch stock data for META (Meta Platforms) and TESLA\n",
"meta = yf.Ticker(\"META\")\n",
"tesla = yf.Ticker(\"TSLA\")\n",
"\n",
"# Get historical stock data\n",
"meta_history = meta.history(start=start_date, end=today)\n",
"tesla_history = tesla.history(start=start_date, end=today)\n",
"\n",
"# Calculate year-to-date gain\n",
"meta_ytd_gain = (meta_history[\"Close\"][-1] - meta_history[\"Close\"][0]) / meta_history[\"Close\"][0] * 100\n",
"tesla_ytd_gain = (tesla_history[\"Close\"][-1] - tesla_history[\"Close\"][0]) / tesla_history[\"Close\"][0] * 100\n",
"\n",
"# Print the results\n",
"print(f\"META year-to-date gain: {meta_ytd_gain:.2f}%\")\n",
"print(f\"TESLA year-to-date gain: {tesla_ytd_gain:.2f}%\")\n",
"```\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[31m\n",
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n",
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
2023-07-28 21:17:51 -07:00
"\n",
"exitcode: 0 (execution succeeded)\n",
"Code output: \n",
2023-07-31 19:22:30 -07:00
"Today's date is: 2023-07-31\n",
"META year-to-date gain: 157.94%\n",
"TESLA year-to-date gain: 145.71%\n",
2023-07-28 21:17:51 -07:00
"\n",
"\n",
"--------------------------------------------------------------------------------\n",
2023-07-31 19:22:30 -07:00
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
"\n",
"Great! The code executed successfully. Today's date is 2023-07-31. The year-to-date gain for META (Meta Platforms) is 157.94%, and the year-to-date gain for TESLA is 145.71%. \n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"If you have any other questions or need further assistance, feel free to ask.\n",
2023-07-28 21:17:51 -07:00
"\n",
"TERMINATE\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"# create an AssistantAgent named \"assistant\"\n",
2023-07-31 19:22:30 -07:00
"assistant = autogen.AssistantAgent(\n",
2023-07-28 21:17:51 -07:00
" name=\"assistant\",\n",
2023-07-31 19:22:30 -07:00
" llm_config={\n",
2023-07-28 21:17:51 -07:00
" \"seed\": 42, # seed for caching and reproducibility\n",
" \"config_list\": config_list, # a list of OpenAI API configurations\n",
" \"temperature\": 0, # temperature for sampling\n",
2023-07-31 19:22:30 -07:00
" }, # configuration for autogen's enhanced inference API which is compatible with OpenAI API\n",
2023-07-28 21:17:51 -07:00
")\n",
"# create a UserProxyAgent instance named \"user_proxy\"\n",
2023-07-31 19:22:30 -07:00
"user_proxy = autogen.UserProxyAgent(\n",
2023-07-28 21:17:51 -07:00
" 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, # set to True or image name like \"python:3\" to use docker\n",
" },\n",
")\n",
"# the assistant receives a message from the user_proxy, which contains the task description\n",
"user_proxy.initiate_chat(\n",
" assistant,\n",
" message=\"\"\"What date is today? Compare the year-to-date gain for META and TESLA.\"\"\",\n",
")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"The example above involves code execution. In FLAML, 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, FLAML defaults to the `flaml/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."
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example Task: Plot Chart"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-07-31 19:22:30 -07:00
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
2023-07-28 21:17:51 -07:00
"\n",
"Plot a chart of their stock price change YTD and save to stock_price_ytd.png.\n",
"\n",
"--------------------------------------------------------------------------------\n",
2023-07-31 19:22:30 -07:00
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
"\n",
"To plot a chart of the stock price change YTD and save it to a file, we'll use the `matplotlib` library. First, you'll need to install the library by running the following command:\n",
"\n",
"```sh\n",
"pip install matplotlib\n",
"```\n",
"\n",
"After installing the library, execute the following Python code to plot the chart and save it to \"stock_price_ytd.png\":\n",
2023-07-28 21:17:51 -07:00
"\n",
"```python\n",
"import matplotlib.pyplot as plt\n",
"\n",
2023-07-31 19:22:30 -07:00
"# Plot the stock price change YTD\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(meta_history.index, meta_history[\"Close\"], label=\"META\")\n",
"plt.plot(tesla_history.index, tesla_history[\"Close\"], label=\"TESLA\")\n",
"plt.xlabel(\"Date\")\n",
"plt.ylabel(\"Stock Price\")\n",
"plt.title(\"Stock Price Change YTD\")\n",
"plt.legend()\n",
"\n",
"# Save the chart to a file\n",
"plt.savefig(\"stock_price_ytd.png\")\n",
"plt.show()\n",
"```\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"This code will create a chart of the stock price change YTD for META and TESLA and save it to a file named \"stock_price_ytd.png\".\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"--------------------------------------------------------------------------------\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",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"exitcode: 1 (execution failed)\n",
"Code output: \n",
"Defaulting to user installation because normal site-packages is not writeable\n",
"Requirement already satisfied: matplotlib in /home/vscode/.local/lib/python3.9/site-packages (3.7.2)\n",
"Requirement already satisfied: pillow>=6.2.0 in /home/vscode/.local/lib/python3.9/site-packages (from matplotlib) (10.0.0)\n",
"Requirement already satisfied: pyparsing<3.1,>=2.3.1 in /home/vscode/.local/lib/python3.9/site-packages (from matplotlib) (3.0.9)\n",
"Requirement already satisfied: fonttools>=4.22.0 in /home/vscode/.local/lib/python3.9/site-packages (from matplotlib) (4.41.1)\n",
"Requirement already satisfied: packaging>=20.0 in /home/vscode/.local/lib/python3.9/site-packages (from matplotlib) (23.1)\n",
"Requirement already satisfied: importlib-resources>=3.2.0 in /home/vscode/.local/lib/python3.9/site-packages (from matplotlib) (6.0.0)\n",
"Requirement already satisfied: python-dateutil>=2.7 in /home/vscode/.local/lib/python3.9/site-packages (from matplotlib) (2.8.2)\n",
"Requirement already satisfied: cycler>=0.10 in /home/vscode/.local/lib/python3.9/site-packages (from matplotlib) (0.11.0)\n",
"Requirement already satisfied: contourpy>=1.0.1 in /home/vscode/.local/lib/python3.9/site-packages (from matplotlib) (1.1.0)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /home/vscode/.local/lib/python3.9/site-packages (from matplotlib) (1.4.4)\n",
"Requirement already satisfied: numpy>=1.20 in /home/vscode/.local/lib/python3.9/site-packages (from matplotlib) (1.25.1)\n",
"Requirement already satisfied: zipp>=3.1.0 in /home/vscode/.local/lib/python3.9/site-packages (from importlib-resources>=3.2.0->matplotlib) (3.16.2)\n",
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.9/site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)\n",
"\n",
"Traceback (most recent call last):\n",
" File \"\", line 5, in <module>\n",
" plt.plot(meta_history.index, meta_history[\"Close\"], label=\"META\")\n",
"NameError: name 'meta_history' is not defined\n",
"\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
"\n",
"I apologize for the error. It seems I forgot to include the previous code to fetch the stock data. Let's combine the code to fetch the stock data and plot the chart:\n",
"\n",
"```python\n",
"import yfinance as yf\n",
"from datetime import datetime\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Get today's date\n",
"today = datetime.now()\n",
"\n",
"# Calculate the start date for year-to-date\n",
"start_date = datetime(today.year, 1, 1)\n",
"\n",
"# Fetch stock data for META (Meta Platforms) and TESLA\n",
"meta = yf.Ticker(\"META\")\n",
"tesla = yf.Ticker(\"TSLA\")\n",
"\n",
"# Get historical stock data\n",
"meta_history = meta.history(start=start_date, end=today)\n",
"tesla_history = tesla.history(start=start_date, end=today)\n",
"\n",
"# Plot the stock price change YTD\n",
"plt.figure(figsize=(10, 5))\n",
"plt.plot(meta_history.index, meta_history[\"Close\"], label=\"META\")\n",
"plt.plot(tesla_history.index, tesla_history[\"Close\"], label=\"TESLA\")\n",
"plt.xlabel(\"Date\")\n",
"plt.ylabel(\"Stock Price\")\n",
"plt.title(\"Stock Price Change YTD\")\n",
2023-07-28 21:17:51 -07:00
"plt.legend()\n",
"\n",
2023-07-31 19:22:30 -07:00
"# Save the chart to a file\n",
"plt.savefig(\"stock_price_ytd.png\")\n",
2023-07-28 21:17:51 -07:00
"plt.show()\n",
"```\n",
"\n",
2023-07-31 19:22:30 -07:00
"This code will fetch the stock data for META and TESLA, create a chart of the stock price change YTD, and save it to a file named \"stock_price_ytd.png\".\n",
2023-07-28 21:17:51 -07:00
"\n",
"--------------------------------------------------------------------------------\n",
2023-07-31 19:22:30 -07:00
"\u001b[31m\n",
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n",
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
2023-07-28 21:17:51 -07:00
"\n",
"exitcode: 0 (execution succeeded)\n",
"Code output: \n",
2023-07-31 19:22:30 -07:00
"Figure(1000x500)\n",
2023-07-28 21:17:51 -07:00
"\n",
"\n",
"--------------------------------------------------------------------------------\n",
2023-07-31 19:22:30 -07:00
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"Great! The code executed successfully and created a chart of the stock price change YTD for META and TESLA. The chart has been saved to a file named \"stock_price_ytd.png\".\n",
"\n",
"If you have any other questions or need further assistance, feel free to ask.\n",
2023-07-28 21:17:51 -07:00
"\n",
"TERMINATE\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"# followup of the previous question\n",
"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",
")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's display the generated figure."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
2023-07-31 19:22:30 -07:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA+gAAAH0CAYAAACuKActAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAADEhklEQVR4nOzdd3hU1dbH8e+k9wQCIUBCr0no0qvSRan2BvaC+lquXrGXq9iu7doFaYogiopYEJAmvffeWwghvZc57x8nGQgJIWWSSfl9nmeeOXPKPmtSIGv23mtbDMMwEBERERERERGHcnJ0ACIiIiIiIiKiBF1ERERERESkQlCCLiIiIiIiIlIBKEEXERERERERqQCUoIuIiIiIiIhUAErQRURERERERCoAJegiIiIiIiIiFYASdBEREREREZEKQAm6iIiIiIiISAWgBF1ERERERESkAlCCLiIiIiIiIlIBKEEXERERERERqQCUoIuIiIiIiIhUAErQRURERERERCoAJegiIiIiIiIiFYASdBEREREREZEKQAm6iIiIiIiISAWgBF1ERERERESkAlCCLiIiIiIiIlIBKEEXERERERERqQCUoIuIiIiIiIhUAErQRURERERERCoAJegiIiIiIiIiFYASdBEREREREZEKQAm6iIiIiIiISAWgBF1ERERERESkAlCCLiIiIiIiIlIBKEEXERERERERqQCUoIuIiIiIiIhUAErQRURERERERCoAJegiIiIiIiIiFYASdBEREREREZEKQAm6iIiIiIiISAWgBF1ERERERESkAlCCLiIiIiIiIlIBKEEXERERERERqQCUoIuIiIiIiIhUAErQRUSkWlu6dCkWi4UffvjBIfefOnUqFouFI0eOOOT+RdGvXz8iIiIcHYaIiEiVpwRdRETK3fbt27nuuuto2LAhHh4e1K9fn4EDB/K///0vz3lvvPEGP//8s2OCLIIjR45gsVhsD2dnZxo0aMCoUaPYsmWLo8O7rISEBF555RXatWuHj48Pnp6eRERE8O9//5tTp045OrxykZmZSZs2bWjatCmpqan5jh85cgQvLy+uv/76PN/rwh5Lly7N97Ph6upKrVq16NGjB88++yzHjh1zwLsVEZGKzmIYhuHoIEREpPpYtWoVV155JQ0aNGDs2LEEBwdz/Phx1qxZw8GDBzlw4IDtXB8fH6677jqmTp1aZvEsXbqUK6+8kjlz5nDdddcV69ojR47QuHFjbr75Zq6++mqys7PZvXs3n332Genp6axZs4b27dsX2kZ2djaZmZm4u7tjsVhK8U6K59ChQwwYMIBjx45x/fXX06tXL9zc3Ni2bRvfffcdNWvWZN++fYDZgx4dHc2OHTvKLb7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bgHg77//ZujQoXTq1ImXXnoJJycnpkyZwlVXXcWKFSvo0qXLJdufN28eALfffnuR31NsbCxDhgxh9OjR3HDDDfzwww/8+9//pk2bNgwdOhQw57RPmjSJm2++mXvvvZfExEQmT57M4MGDWbduXb7h/jNnziQxMZH7778fi8XC22+/zejRozl06BCurq4A/Pbbb9x44420adOGiRMnEhsby9133039+vXzxXj//fczdepU7rzzTh599FEOHz7Mxx9/zObNm1m5cqWtzYL4+/vz0Ucfcf311zNp0iR27drFmTNn+OOPP8pk6kH37t1p2rQpCxcutHvbIiJSiRkiIiLl6K+//jKcnZ0NZ2dno3v37sbTTz9tLFiwwMjIyMh3rre3tzF27Nh8+0eOHGm4ubkZBw8etO07deqU4evra/Tp08e278UXXzQAY+7cufnasFqthmEYxpIlSwzAmDNnjpGYmGj07dvXqFWrlrF58+bLvpfDhw8bgPHKK68YZ8+eNSIjI42lS5caHTp0MADjxx9/NAzDMKZMmWIARq9evYysrKw8beQeO3z4sGEYhhEXF2f4+voaXbt2NVJTUwuM2Wq1Gs2bNzcGDx5s22cYhpGSkmI0btzYGDhwYKFxd+jQwfD397/s+8vVt29fAzCmT59u25eenm4EBwcbY8aMse3Lysoy0tPT81wbGxtr1KlTx7jrrrts+3K/boGBgUZMTIxt/y+//GIAxq+//mrb16ZNGyMkJMRITEy07Vu6dKkBGA0bNrTtW7FihQEY3377bZ77//nnnwXuv5RrrrnG8Pf3N5ydnY0JEyYUeu748eONS/0plfse33nnnUteP2LECAMw4uPjixSbiIhUfRriLiIi5WrgwIGsXr2a4cOHs3XrVt5++20GDx5M/fr1bT27hcnOzuavv/5i5MiRNGnSxLa/bt263HLLLfzzzz8kJCQA5lDudu3aMWrUqHztXNwrGh8fz6BBg9izZw9Lly69bHG3C7300kvUrl2b4OBg+vXrx8GDB3nrrbcYPXp0nvPuvffey843X7hwIYmJiTzzzDN4eHgUGPOWLVvYv38/t9xyC+fOnSM6Opro6GiSk5Pp378/y5cvx2q1XvIeCQkJ+Pr6Fvn9gVmw78K51G5ubnTp0oVDhw7Z9jk7O+Pm5gaYw81jYmLIysriiiuuYNOmTfnavPHGG6lRo4btde/evQFsbZ46dYrt27dzxx134OPjYzuvb9++tGnTJk9bc+bMwd/fn4EDB9q+HtHR0XTq1AkfH598w+wv5ZNPPiEjI4PQ0FBeeOGFIl1TUrnvKTExsUzvIyIilYeGuIuISLnr3Lkzc+fOJSMjg61bt/LTTz/x/vvvc91117FlyxbCwsIuee3Zs2dJSUmhZcuW+Y61bt0aq9XK8ePHCQ8P5+DBg4wZM6ZIMT322GOkpaWxefNmW5Gworrvvvu4/vrrcXJyIiAggPDwcNzd3fOd17hx48u2lTs8vrDh//v37wdg7NixlzwnPj4+T/J7IT8/vzyJdVGEhITk+1CjRo0abNu2Lc++adOm8d///pc9e/aQmZlp21/
2023-07-28 21:17:51 -07:00
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from IPython.display import Image\n",
"\n",
"Image(filename='coding/stock_price_ytd.png')"
]
},
{
2023-07-31 19:22:30 -07:00
"attachments": {},
2023-07-28 21:17:51 -07:00
"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": 6,
"metadata": {},
"outputs": [],
"source": [
"from typing import Dict, Union\n",
"from IPython import get_ipython\n",
"\n",
2023-07-31 19:22:30 -07:00
"class IPythonUserProxyAgent(autogen.UserProxyAgent):\n",
2023-07-28 21:17:51 -07:00
" 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 super().generate_init_message(*args, **kwargs) + \"\"\"\n",
"If you suggest code, the code will be executed in IPython.\"\"\"\n",
"\n",
" def run_code(self, code, **kwargs):\n",
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",
2023-07-28 21:17:51 -07:00
" 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",
2023-07-31 19:22:30 -07:00
" return exitcode, log, None"
2023-07-28 21:17:51 -07:00
]
},
{
2023-07-31 19:22:30 -07:00
"attachments": {},
2023-07-28 21:17:51 -07:00
"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 plot directly."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-07-31 19:22:30 -07:00
"\u001b[33mipython_user_proxy\u001b[0m (to assistant):\n",
2023-07-28 21:17:51 -07:00
"\n",
"Plot a chart of META and TESLA stock price change YTD\n",
"If you suggest code, the code will be executed in IPython.\n",
"\n",
"--------------------------------------------------------------------------------\n",
2023-07-31 19:22:30 -07:00
"\u001b[33massistant\u001b[0m (to ipython_user_proxy):\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"To plot a chart of META (Facebook) and TESLA stock price change YTD, you can use the `yfinance` library to fetch the stock data and `matplotlib` to plot the chart. First, you need to install the `yfinance` library if you haven't already:\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"```sh\n",
"pip install yfinance\n",
2023-07-28 21:17:51 -07:00
"```\n",
"\n",
2023-07-31 19:22:30 -07:00
"Now, you can execute the following Python code to plot the chart:\n",
2023-07-28 21:17:51 -07:00
"\n",
"```python\n",
"import yfinance as yf\n",
"import matplotlib.pyplot as plt\n",
2023-07-31 19:22:30 -07:00
"import datetime\n",
"\n",
"# Get the current date\n",
"today = datetime.date.today()\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"# Calculate the start date for YTD\n",
"start_date = datetime.date(today.year, 1, 1)\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"# Download stock data for META (Facebook) and TESLA\n",
"meta_data = yf.download('FB', start=start_date, end=today)\n",
"tesla_data = yf.download('TSLA', start=start_date, end=today)\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"# Calculate the percentage change in stock prices\n",
"meta_pct_change = meta_data['Close'].pct_change().cumsum() * 100\n",
"tesla_pct_change = tesla_data['Close'].pct_change().cumsum() * 100\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"# Plot the chart\n",
"plt.figure(figsize=(12, 6))\n",
"plt.plot(meta_pct_change, label='META (Facebook)')\n",
"plt.plot(tesla_pct_change, label='TESLA')\n",
2023-07-28 21:17:51 -07:00
"plt.xlabel('Date')\n",
2023-07-31 19:22:30 -07:00
"plt.ylabel('Percentage Change YTD')\n",
"plt.title('META (Facebook) vs TESLA Stock Price Change YTD')\n",
"plt.legend()\n",
"plt.grid()\n",
2023-07-28 21:17:51 -07:00
"plt.show()\n",
"```\n",
"\n",
2023-07-31 19:22:30 -07:00
"This code will fetch the stock data for META (Facebook) and TESLA, calculate the percentage change in stock prices YTD, and plot the chart.\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"--------------------------------------------------------------------------------\n",
"\u001b[31m\n",
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is sh)...\u001b[0m\n"
2023-07-28 21:17:51 -07:00
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-07-31 19:22:30 -07:00
"\u001b[31m\n",
">>>>>>>> EXECUTING CODE BLOCK 1 (inferred language is python)...\u001b[0m\n"
2023-07-28 21:17:51 -07:00
]
},
{
"data": {
2023-07-31 19:22:30 -07:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA/AAAAIjCAYAAACkgvA7AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAAC38UlEQVR4nOzdd3RU1dfG8e+k91BDKIHQO1KlSlGKCAgoAioCFlQQFbuoWFAsiIigP8srgiIoUkRQkI50BJUmHekllAABAqTd94/DTAhJYBImmZTns9asubl1T+4wZM85Zx+bZVkWIiIiIiIiIpKjebg7ABERERERERG5PiXwIiIiIiIiIrmAEngRERERERGRXEAJvIiIiIiIiEguoAReREREREREJBdQAi8iIiIiIiKSCyiBFxEREREREckFlMCLiIiIiIiI5AJK4EVERERERERyASXwIiK53IEDB/Dz82PFihXuDuWalixZgs1mY+rUqdl+7TfffBObzcaJEyeuuV/Pnj3p3r17NkUlOZGz75Ws0rdvXyIjI91ybWfZbDYGDhzo7jBERPIlJfAiku+MHz8em82GzWZj+fLlqbZblkVERAQ2m42OHTum2GY/Lq3H448/7khSnXlcqXv37thsNl566aUMv56hQ4fSsGFDmjZt6ljXt2/fdK/7+++/Z/ga+cVLL73EtGnT2LBhg1vjuNb9u/LRt29fAFq2bJnuPlWqVElx7k2bNtGtWzfKlCmDn58fJUuWpE2bNowZMybFfpGRkane/9cye/ZsbDYbJUqUICkpKUOvd9asWbRo0YKwsDACAgIoV64c3bt3T/FePXz4MG+++Sbr16/P0Lmz05WfLTabDT8/PypVqsTAgQOJi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ly1uxsbGO9QMHDrS8vLysDRs2pHnctT7r03tvWJZlLVy40PL397fKlCmT4noiImlRF3oRybfuvfdeTp48yfz58x3r4uLimDp1Kvfdd1+2xTFx4kTatGlDq1atqFq1KhMnTnT62BkzZtCwYUOCgoIydM1ly5Zxzz33ULp0aXx9fYmIiOCZZ55Js5vstm3b6N69O0WLFsXf35/KlSunamE6dOgQDz30EMWKFcPX15fq1avzzTffpHntxMREXnnlFcLDwwkMDOTOO+/kwIEDqfabMmUK9erVw9/fnyJFitCrVy8OHTqUar9FixZxyy23EBgYSIECBejcuTNbt2697u9g3759VKhQgRo1aqTo3tymTRvOnz+f4n2Rlho1atCqVatU65OSkihZsiTdunVzrPvxxx+pV68ewcHBhISEULNmTT755JPrxuhqu3fvpnr16hQoUCDVtrCwsEyf9+eff+bChQvcc8899OzZk+nTp3Px4sXrHnfixAliYmJSDP9IK6YlS5bQoEEDAB588EFHN+Tx48c79nX2/eLM+/lq6b1XnHXrrbcCpicFmCESQUFB7N69mzvuuIPg4GDuv/9+x7arx8AnJSXxySefULNmTfz8/ChatCi3334769atS7Hf999/7/gdFCpUiJ49e6b5b+tqw4cP59y5c4wdO5bixYun2l6hQgWefvrpVOtnzJhBjRo1HP/mrx6es2/fPgYMGEDlypXx9/encOHC3HPPPezduzfFfvbu5StWrODZZ5+laNGiBAYG0rVrV44fP57qd/Hmm29SokQJAgICaNWqFVu2bCEyMtIxpMTu9OnTDBo0iIiICHx9falQoQIffPDBdXs4eHl58dVXX7Fnzx7eeecdAP766y/+97//8dxzz7m8lfzWW29lyJAh7Nu3j++//96l5xaRvEcJvIjkW5GRkTRu3JgffvjBsW7OnDmcOXOGnj17pnvcxYsXOXHiRKpHXFxchmM4fPgwixcvdoy3vPfee5k6dapT54qPj2ft2rXUrVs33X2ujvHMmTOASXZiY2Pp378/Y8aMoV27dowZMybV0ICNGzfSsGFDFi1aRL9+/fjkk0/o0qULs2bNcuwTFRVFo0aNWLBgAQMHDuSTTz6hQoUKPPzww4waNSpVTMOGDeO3337jpZde4qmnnmL+/Pm0bt06xZcH48ePp3v37nh6evLee+/Rr18/pk+fTrNmzTh9+rRjvwULFtCuXTuOHTvGm2++ybPPPsvKlStp2rRpqiThSrt376Z58+YEBwezZMkSihUr5thWrVo1/P39r1sUsEePHixdupSjR4+mWL98+XIOHz7seA/Nnz+fe++9l4IFC/LBBx/w/vvv07JlS5cXHUxMTEzzfXn+/HnHPmXKlOGvv/5i8+bNLr32xIkTadWqFeHh4fTs2ZOzZ8+meI+kJywsDH9/f2bNmkV0dHS6+1WtWpWhQ4cC8OijjzJhwgQmTJhA8+bNAeffL868n692rfeKs3bv3g1A4cKFHesSEhJo164dYWFhjBgxgrvvvjvd4x9++GFHIvrBBx/w8ssv4+fnx+rVqx37DBs2jN69e1OxYkVGjhzJoEGDWLhwIc2bN0/xO0jLrFmzKFeuHE2aNHH6NS1fvpwBAwbQs2dPhg8fzsWLF7n77rs5efKkY5+1a9eycuVKevbsyejRo3n88cdZuHAhLVu2JDY2NtU5n3zySTZs2MAbb7xB//79mTVrVqpieYMHD+att96ifv36fPjhh1SsWJF27dqleJ8DxMbG0qJFC77//nt69+7N6NGjadq0KYMHD+bZZ5+97utr1KgR/fv358MPP2TTpk089thjREZG8sYbbzj9O8qIBx54AIB58+ZlyflFJA9xdxcAEZHsdmVXxk8//dQKDg52dFu85557rFatWlmWlXYXYiDdxw8//JDm9a7VrXLEiBGWv7+/FRMTY1mWZe3YscMCrJ9//vm6r2PXrl0WYI0ZMybVtj59+qQZoz2OtLppvvfee5bNZrP27dvnWNe8eXMrODg4xTrLsqykpCTH8sMPP2wVL17cOnHiRIp9evbsaYWGhjquZe9CX7J
2023-07-28 21:17:51 -07:00
"text/plain": [
2023-07-31 19:22:30 -07:00
"<Figure size 1200x600 with 1 Axes>"
2023-07-28 21:17:51 -07:00
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-07-31 19:22:30 -07:00
"\u001b[33mipython_user_proxy\u001b[0m (to assistant):\n",
2023-07-28 21:17:51 -07:00
"\n",
"exitcode: 0 (execution succeeded)\n",
"Code output: \n",
2023-07-31 19:22:30 -07:00
"Defaulting to user installation because normal site-packages is not writeable\n",
"Requirement already satisfied: yfinance in /home/vscode/.local/lib/python3.9/site-packages (0.2.26)\n",
"Requirement already satisfied: multitasking>=0.0.7 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (0.0.11)\n",
"Requirement already satisfied: numpy>=1.16.5 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (1.25.1)\n",
"Requirement already satisfied: beautifulsoup4>=4.11.1 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (4.12.2)\n",
"Requirement already satisfied: lxml>=4.9.1 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (4.9.3)\n",
"Requirement already satisfied: pandas>=1.3.0 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (1.3.3)\n",
"Requirement already satisfied: requests>=2.31 in /usr/local/lib/python3.9/site-packages (from yfinance) (2.31.0)\n",
"Requirement already satisfied: pytz>=2022.5 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (2023.3)\n",
"Requirement already satisfied: html5lib>=1.1 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (1.1)\n",
"Requirement already satisfied: frozendict>=2.3.4 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (2.3.8)\n",
"Requirement already satisfied: appdirs>=1.4.4 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (1.4.4)\n",
"Requirement already satisfied: soupsieve>1.2 in /home/vscode/.local/lib/python3.9/site-packages (from beautifulsoup4>=4.11.1->yfinance) (2.4.1)\n",
"Requirement already satisfied: webencodings in /home/vscode/.local/lib/python3.9/site-packages (from html5lib>=1.1->yfinance) (0.5.1)\n",
"Requirement already satisfied: six>=1.9 in /usr/local/lib/python3.9/site-packages (from html5lib>=1.1->yfinance) (1.16.0)\n",
"Requirement already satisfied: python-dateutil>=2.7.3 in /home/vscode/.local/lib/python3.9/site-packages (from pandas>=1.3.0->yfinance) (2.8.2)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.9/site-packages (from requests>=2.31->yfinance) (2023.5.7)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.9/site-packages (from requests>=2.31->yfinance) (3.4)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.9/site-packages (from requests>=2.31->yfinance) (3.2.0)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.9/site-packages (from requests>=2.31->yfinance) (2.0.3)\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.0.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.2.1\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
"Note: you may need to restart the kernel to use updated packages.\n",
"\n",
"[*********************100%***********************] 1 of 1 completed\n",
"[*********************100%***********************] 1 of 1 completed\n",
"\n",
"1 Failed download:\n",
"['FB']: Exception('%ticker%: No timezone found, symbol may be delisted')\n",
2023-07-28 21:17:51 -07:00
"\n",
"\n",
2023-07-31 19:22:30 -07:00
"--------------------------------------------------------------------------------\n",
"\u001b[33massistant\u001b[0m (to ipython_user_proxy):\n",
"\n",
"I apologize for the issue. It seems that the stock symbol for Meta Platforms (formerly Facebook) has changed from 'FB' to 'META'. Let's update the code with the correct stock symbol and try again:\n",
2023-07-28 21:17:51 -07:00
"\n",
"```python\n",
"import yfinance as yf\n",
2023-07-31 19:22:30 -07:00
"import matplotlib.pyplot as plt\n",
"import datetime\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"# Get the current date\n",
"today = datetime.date.today()\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"# Calculate the start date for YTD\n",
"start_date = datetime.date(today.year, 1, 1)\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"# Download stock data for META (Facebook) and TESLA\n",
"meta_data = yf.download('META', start=start_date, end=today)\n",
"tesla_data = yf.download('TSLA', start=start_date, end=today)\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"# Calculate the percentage change in stock prices\n",
"meta_pct_change = meta_data['Close'].pct_change().cumsum() * 100\n",
"tesla_pct_change = tesla_data['Close'].pct_change().cumsum() * 100\n",
"\n",
"# Plot the chart\n",
"plt.figure(figsize=(12, 6))\n",
"plt.plot(meta_pct_change, label='META (Facebook)')\n",
"plt.plot(tesla_pct_change, label='TESLA')\n",
"plt.xlabel('Date')\n",
"plt.ylabel('Percentage Change YTD')\n",
"plt.title('META (Facebook) vs TESLA Stock Price Change YTD')\n",
"plt.legend()\n",
"plt.grid()\n",
"plt.show()\n",
2023-07-28 21:17:51 -07:00
"```\n",
"\n",
2023-07-31 19:22:30 -07:00
"This code should now fetch the stock data for META (Facebook) and TESLA, calculate the percentage change in stock prices YTD, and plot the chart.\n",
2023-07-28 21:17:51 -07:00
"\n",
"--------------------------------------------------------------------------------\n",
2023-07-31 19:22:30 -07:00
"\u001b[31m\n",
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n"
2023-07-28 21:17:51 -07:00
]
},
{
"data": {
2023-07-31 19:22:30 -07:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA/AAAAIjCAYAAACkgvA7AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6d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HwNXV1bguIyODLl264OHhwffff0+/fv1yPf755583JqLffPMN77//PjY2Nuzfv9+4zxdffMGwYcOoVq0akydPZty4cWzZsoW2bdtmeQ1ysmrVKqpUqULLli1Nfk67d+9mzJgxDB48mG+//ZaUlBT69evHrVu3jPscOnSIvXv3MnjwYKZNm8ZLL73Eli1baN++PUlJSdnO+eqrrxIcHMwnn3zCyy+/zKpVq7IVyxs/fjyffvopTZo04bvvvqNatWp06dIly/scICkpiXbt2vH3338zbNgwpk2bRqtWrRg/fjxvvvlmns/vscce4+WXX+a7777j+PHjvPjii/j5+fHJJ5+Y/Brlx7PPPgvAxo0bC+X8QohSxNxdAIQQoqjd25Xxp59+UhwdHY3dFgcMGKB06NBBUZScuxADuf78888/OV7vQd0qv//+e8XW1laJi4tTFEVRzpw5owDK8uXL83we586dUwBl+vTp2bYNHz48xxgz48ipm+ZXX32laDQa5dKlS8Z1bdu2VRwdHbOsUxRFMRgMxuXnn39e8fLyUm7evJlln8GDByvOzs7Ga2V2offx8TE+X0VRlEWLFimAMnXqVEV
2023-07-28 21:17:51 -07:00
"text/plain": [
2023-07-31 19:22:30 -07:00
"<Figure size 1200x600 with 1 Axes>"
2023-07-28 21:17:51 -07:00
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-07-31 19:22:30 -07:00
"\u001b[33mipython_user_proxy\u001b[0m (to assistant):\n",
2023-07-28 21:17:51 -07:00
"\n",
"exitcode: 0 (execution succeeded)\n",
"Code output: \n",
2023-07-31 19:22:30 -07:00
"[*********************100%***********************] 1 of 1 completed\n",
"[*********************100%***********************] 1 of 1 completed\n",
2023-07-28 21:17:51 -07:00
"\n",
"\n",
2023-07-31 19:22:30 -07:00
"--------------------------------------------------------------------------------\n",
"\u001b[33massistant\u001b[0m (to ipython_user_proxy):\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"I'm glad the code executed successfully and you were able to plot the chart of META (Facebook) and TESLA stock price change YTD. If you have any further questions or need assistance with anything else, please feel free to ask.\n",
2023-07-28 21:17:51 -07:00
"\n",
"TERMINATE\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"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\") or x.get(\"content\", \"\").rstrip().endswith('\"TERMINATE\".'),\n",
")\n",
"assistant.reset()\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 change 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",
2023-08-14 00:09:45 -07:00
"version": "3.9.16"
2023-07-28 21:17:51 -07:00
},
"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<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
}