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-27 15:16:52 -07:00
"FLAML 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-08-14 00:09:45 -07:00
"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-27 15:16:52 -07:00
"# %pip install flaml[autogen]~=2.0.1"
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-27 15:16:52 -07:00
" \"model\": [\"gpt-4\", \"gpt-4-0314\", \"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",
2023-08-27 15:16:52 -07:00
"To solve this task, we will need to do the following:\n",
2023-07-31 19:22:30 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"1. Get the current date: We can use Python's built-in datetime module to get the current date.\n",
"\n",
"2. Get the year-to-date (YTD) gain for META (Facebook) and TESLA: We can use the yfinance module in Python to download the stock data. The YTD gain can be calculated as the percentage change in the closing price from the first trading day of the year to the most recent trading day.\n",
2023-07-31 19:22:30 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"Here is the Python code to perform these tasks:\n",
2023-07-28 21:17:51 -07:00
"\n",
"```python\n",
2023-08-27 15:16:52 -07:00
"# python code\n",
"import datetime\n",
2023-07-28 21:17:51 -07:00
"import yfinance as yf\n",
"\n",
2023-08-27 15:16:52 -07:00
"# Get the current date\n",
"today = datetime.date.today()\n",
"print(\"Today's date is:\", today)\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"# Get the stock data for META and TESLA\n",
"meta = yf.Ticker(\"META\")\n",
2023-07-31 19:22:30 -07:00
"tesla = yf.Ticker(\"TSLA\")\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"# Get the historical market data\n",
"meta_hist = meta.history(period=\"ytd\")\n",
"tesla_hist = tesla.history(period=\"ytd\")\n",
"\n",
"# Calculate the YTD gain\n",
"meta_ytd_gain = ((meta_hist['Close'][-1] - meta_hist['Close'][0]) / meta_hist['Close'][0]) * 100\n",
"tesla_ytd_gain = ((tesla_hist['Close'][-1] - tesla_hist['Close'][0]) / tesla_hist['Close'][0]) * 100\n",
"\n",
"print(\"META's YTD gain is: {:.2f}%\".format(meta_ytd_gain))\n",
"print(\"TESLA's YTD gain is: {:.2f}%\".format(tesla_ytd_gain))\n",
"```\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"Please install the yfinance module if it's not installed yet. You can install it using pip:\n",
2023-07-31 19:22:30 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"```sh\n",
"# sh code\n",
"pip install yfinance\n",
2023-07-28 21:17:51 -07:00
"```\n",
"\n",
2023-08-27 15:16:52 -07:00
"After running the Python code, you will get the current date and the YTD gain for META and TESLA.\n",
"\n",
2023-07-31 19:22:30 -07:00
"--------------------------------------------------------------------------------\n",
"\u001b[31m\n",
2023-08-27 15:16:52 -07:00
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n",
2023-07-31 19:22:30 -07:00
"\u001b[31m\n",
2023-08-27 15:16:52 -07:00
">>>>>>>> EXECUTING CODE BLOCK 1 (inferred language is sh)...\u001b[0m\n",
2023-07-31 19:22:30 -07:00
"\u001b[33muser_proxy\u001b[0m (to assistant):\n",
"\n",
2023-08-27 15:16:52 -07:00
"exitcode: 0 (execution succeeded)\n",
2023-07-31 19:22:30 -07:00
"Code output: \n",
2023-08-27 15:16:52 -07:00
"Today's date is: 2023-08-27\n",
"META's YTD gain is: 128.88%\n",
"TESLA's YTD gain is: 120.71%\n",
"\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",
2023-08-27 15:16:52 -07:00
"Requirement already satisfied: pandas>=1.3.0 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (1.3.3)\n",
2023-07-31 19:22:30 -07:00
"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",
2023-08-27 15:16:52 -07:00
"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: pytz>=2022.5 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (2023.3)\n",
2023-07-31 19:22:30 -07:00
"Requirement already satisfied: frozendict>=2.3.4 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (2.3.8)\n",
2023-08-27 15:16:52 -07:00
"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: numpy>=1.16.5 in /home/vscode/.local/lib/python3.9/site-packages (from yfinance) (1.25.1)\n",
2023-07-31 19:22:30 -07:00
"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: 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: certifi>=2017.4.17 in /usr/local/lib/python3.9/site-packages (from requests>=2.31->yfinance) (2023.5.7)\n",
2023-08-27 15:16:52 -07:00
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.9/site-packages (from requests>=2.31->yfinance) (3.2.0)\n",
2023-07-31 19:22:30 -07:00
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.9/site-packages (from requests>=2.31->yfinance) (3.4)\n",
"\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
"\n",
2023-08-27 15:16:52 -07:00
"Great! The code has been executed successfully. \n",
2023-07-28 21:17:51 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"As of today (August 27, 2023), the year-to-date gain for META (Facebook) is approximately 128.88%, and for TESLA, it's approximately 120.71%.\n",
2023-07-31 19:22:30 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"Please let me know if you need help with anything else.\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",
2023-08-27 15:16:52 -07:00
"To plot a chart of the year-to-date (YTD) stock price changes for META and TESLA and save it to a file, we can use the matplotlib library in Python. Here is the Python code to do this:\n",
2023-07-28 21:17:51 -07:00
"\n",
"```python\n",
2023-08-27 15:16:52 -07:00
"# python code\n",
"# filename: plot_stock_price.py\n",
2023-07-28 21:17:51 -07:00
"import matplotlib.pyplot as plt\n",
"\n",
2023-08-27 15:16:52 -07:00
"# Plot the closing prices of META and TESLA\n",
"plt.figure(figsize=(14, 7))\n",
"plt.plot(meta_hist['Close'], label='META')\n",
"plt.plot(tesla_hist['Close'], label='TESLA')\n",
"plt.title('Year-to-Date Stock Price Change for META and TESLA')\n",
"plt.xlabel('Date')\n",
"plt.ylabel('Closing Price')\n",
2023-07-31 19:22:30 -07:00
"plt.legend()\n",
"\n",
2023-08-27 15:16:52 -07:00
"# Save the plot to a file\n",
"plt.savefig('stock_price_ytd.png')\n",
2023-07-31 19:22:30 -07:00
"```\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"After running this Python code, a chart of the YTD stock price changes for META and TESLA will be saved to a file named 'stock_price_ytd.png'. \n",
"\n",
"Please make sure you have the matplotlib library installed. If not, you can install it using pip:\n",
"\n",
"```sh\n",
"# sh code\n",
"pip install matplotlib\n",
"```\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"--------------------------------------------------------------------------------\n",
"\u001b[31m\n",
2023-08-27 15:16:52 -07:00
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n",
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",
2023-07-31 19:22:30 -07:00
"exitcode: 1 (execution failed)\n",
"Code output: \n",
"Traceback (most recent call last):\n",
2023-08-27 15:16:52 -07:00
" File \"\", line 7, in <module>\n",
" plt.plot(meta_hist['Close'], label='META')\n",
"NameError: name 'meta_hist' is not defined\n",
2023-07-31 19:22:30 -07:00
"\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33massistant\u001b[0m (to user_proxy):\n",
"\n",
2023-08-27 15:16:52 -07:00
"I apologize for the oversight. The error occurred because the variables `meta_hist` and `tesla_hist` were defined in the previous script and are not available in the current script. We need to fetch the stock data again in the current script. Here is the corrected Python code:\n",
2023-07-31 19:22:30 -07:00
"\n",
"```python\n",
2023-08-27 15:16:52 -07:00
"# python code\n",
"# filename: plot_stock_price.py\n",
2023-07-31 19:22:30 -07:00
"import matplotlib.pyplot as plt\n",
2023-08-27 15:16:52 -07:00
"import yfinance as yf\n",
2023-07-31 19:22:30 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"# Get the stock data for META and TESLA\n",
2023-07-31 19:22:30 -07:00
"meta = yf.Ticker(\"META\")\n",
"tesla = yf.Ticker(\"TSLA\")\n",
"\n",
2023-08-27 15:16:52 -07:00
"# Get the historical market data\n",
"meta_hist = meta.history(period=\"ytd\")\n",
"tesla_hist = tesla.history(period=\"ytd\")\n",
"\n",
"# Plot the closing prices of META and TESLA\n",
"plt.figure(figsize=(14, 7))\n",
"plt.plot(meta_hist['Close'], label='META')\n",
"plt.plot(tesla_hist['Close'], label='TESLA')\n",
"plt.title('Year-to-Date Stock Price Change for META and TESLA')\n",
"plt.xlabel('Date')\n",
"plt.ylabel('Closing Price')\n",
2023-07-28 21:17:51 -07:00
"plt.legend()\n",
"\n",
2023-08-27 15:16:52 -07:00
"# Save the plot to a file\n",
"plt.savefig('stock_price_ytd.png')\n",
2023-07-28 21:17:51 -07:00
"```\n",
"\n",
2023-08-27 15:16:52 -07:00
"After running this Python code, a chart of the YTD stock price changes for META and TESLA will be saved 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",
"\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-08-27 15:16:52 -07:00
"Great! The code has been executed successfully and the chart of the Year-to-Date stock price changes for META and TESLA has been saved to a file named 'stock_price_ytd.png'. \n",
2023-07-31 19:22:30 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"You can now view this image file to see the plotted chart.\n",
"\n",
"Please let me know if you need help with anything else.\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-08-27 15:16:52 -07:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABXgAAAK8CAYAAABV1dcbAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3hUZfrG8e+k94SEEkoavffeERQQccGCYAPsirr2XXTturr6W9vaFQEFLCgWEAURlN57L0kINZCEFBLSZs7vj5MZiAkhZZIh4f5c11xzcs6Z97wzmYSLO888r8UwDAMRERERERERERERqXbcXD0BERERERERERERESkfBbwiIiIiIiIiIiIi1ZQCXhEREREREREREZFqSgGviIiIiIiIiIiISDWlgFdERERERERERESkmlLAKyIiIiIiIiIiIlJNKeAVERERERERERERqaYU8IqIiIiIiIiIiIhUUwp4RURERERERERERKopBbwiIiIiIiIiIiIi1ZQCXhEREREREREREZFqSgGviIiIiIiIiIiISDWlgFdERERERERERESkmlLAKyIiIiIiIiIiIlJNKeAVERERERERERERqaYU8IqIiIiIiIiIiIhUUwp4RURERERERERERKopBbwiIiIiIiIiIiIi1ZQCXhEREREREREREZFqSgGviIiIiIiIiIiISDWlgFdERERERERERESkmlLAKyIiIiIiIiIiIlJNKeAVERERERERERERqaYU8IqIiIiIiIiIiIhUUwp4RURERERERERERKopBbwiIiIiIiIiIiIi1ZQCXhEREREREREREZFqSgGviIiIiIiIiIiISDWlgFdERERERERERESkmlLAKyIiIiIiIiIiIlJNKeAVERERERERERERqaYU8IqIiIiIiIiIiIhUUwp4RURERERERERERKopBbwiIiIiIiIiIiIi1ZQCXhEREREREREREZFqSgGviIiIiIiIiIiISDWlgFdERERERERERESkmlLAKyIiIiIiIiIiIlJNKeAVERERERERERERqaYU8IqIiIiIiIiIiIhUUwp4RURERERERERERKopBbwiIiIiIiIiIiIi1ZQCXhEREREREREREZFqSgGviIiIiIiIiIiISDWlgFdERERERERERESkmlLAKyIiIiIiIiIiIlJNKeAVERERERERERERqaYU8IqIiIiIiIiIiIhUUwp4RURERERERERERKopBbwiIiIiIiIiIiIi1ZQCXhEREREREREREZFqSgGviIiIiIiIiIiISDWlgFdERERERERERESkmlLAKyIiIiIiIiIiIlJNKeAVERERERERERERqaYU8IqIiIiIiIiIiIhUUwp4RURERERERERERKopBbwiIiIiIiIiIiIi1ZQCXhEREREREREREZFqSgGviIiIiIiIiIiISDWlgFdERERERERERESkmlLAKyIiInKJeu6557BYLCQlJbnk+hMmTCA6Otol1y4ti8XC/fff7+ppVLrXX3+dxo0b4+7uTseOHV09HfmLgQMHMnDgQFdPQ0RERC5SCnhFRESqseHDh1OrVi0SExOLHEtLS6N+/fr06NEDm83mgtnBypUree6550hNTXX62BMmTMBisThuAQEBNG7cmOuuu47vvvuuQs951qxZvPXWW86b7Dnmzp3LgAEDqFu3Ln5+fjRu3JgxY8bw66+/Os45evQozz33HJs3b66UOTjDtGnTCr3+Pj4+NG/enPvvv7/Y9+PF5sCBA9x99900btwYHx8fgoKC6NOnD2+//TZnzpxx9fSq1MKFC3niiSfo06cPU6dO5d///nelXs/+sxsUFFTsa71v3z7H++r//u//HPv/+OOPQu+5v96++uorxx8tLnQ7Nyy1Wq00aNAAi8XCL7/8UqnPvbKU9Xn/9ffnX3+WzxUfH8/EiRNp0qQJPj4+hIeH079/f5599tlC5w0cOJC2bduWes67du1yXK8y/o0QERG5lHi4egIiIiJSfu+//z5t27bl4YcfZtasWYWOPfnkkyQlJfHrr7/i5uaav+muXLmS559/ngkTJhASEuL08b29vfn0008BOHPmDAcPHmTu3Llcd911DBw4kB9//JGgoKAyjztr1iy2b9/OQw895NT5/t///R+PP/44AwYMYPLkyfj5+bF//34WLVrEV199xbBhwwAz4H3++eeJjo6+6KspX3jhBWJiYsjOzmb58uV88MEHzJ8/n+3bt+Pn51fiYz/55BOX/PHh559/5vrrr8fb25tbb72Vtm3bkpuby/Lly3n88cfZsWMHH3/8cZXPy1UWL16Mm5sbU6ZMwcvLq0qu6eHhQVZWFnPnzmXMmDGFjs2cORMfHx+ys7OLfeyDDz5It27diuzv1asXrVu3pmnTpo59p0+f5t5772X06NFcc801jv316tVzbC9evJhjx44RHR3NzJkzGT58eEWfXpW75ppryvy8z/39eS53d3fH9v79++nWrRu+vr7cdtttREdHc+zYMTZu3Mh//vMfnn/++XLPecaMGYSHh3Pq1Cm+/fZb7rjjjnKPJSIicqlTwCsiIlKNxcTE8Oyzz/KPf/yDCRMmcMUVVwCwbt06PvzwQx577DE6dOhQqXPIzs7Gy8vLJSGyh4cHN998c6F9L730Eq+++iqTJ0/mzjvv5Ouvv67yeRUnPz+fF198kcsvv5yFCxcWOX7ixAkXzKrihg8fTteuXQG44447CAsL44033uDHH39k3LhxxT4mMzMTf39/PD09q3KqAMTFxTF27FiioqJYvHgx9evXdxybNGkS+/fv5+eff67yebnSiRMn8PX1dVq4axgG2dnZ+Pr6nvccb29v+vTpw5dfflkk4J01axYjRozgu+++K/ax/fr147rrrjvv2O3bt3dsJyUlce+999K+ffsivyvsZsyYQefOnRk/fjxPPvmk4/1ZnbRv377Mz7u4359/9eabb3L69Gk2b95MVFRUoWMV+Z1lGAazZs3ixhtvJC4ujpkzZyrgFRERqQC1aBAREanmHnnkEdq3b899991HdnY2VquVe+65h6ioKJ599ll2797NddddR2hoKD4+PnTt2pWffvqp0BgpKSk89thjtGvXjoCAAIKCghg+fDhbtmwpdJ79I9JfffUV//rXv2jYsCF+fn6kp6cXmddzzz3H448/DphBtP3jv/Hx8cDZwLNJkyZ4e3sTHR3Nk08+SU5OToVfk3/+859cccUVzJ49m7179zr2//jjj4wYMYIGDRrg7e1NkyZNePHFF7FarY5zBg4cyM8//8zBgwcdcz63T2xOTg7PPvssTZs2xdvbm4iICJ544okLzjspKYn09HT69OlT7PG6desC5mtsr06cOHGiYw7Tpk1znDt79my6dOmCr68vtWvX5uabb+bIkSNFxty9ezdjxoyhTp06+Pr60qJFC5566qkS53nw4EGaNm1K27Zty9Vq4bLLLgPMIBXMj4IHBARw4MABrrzySgIDA7npppscx/7ag9dms/H222/Trl07fHx8qFOnDsOGDWP9+vWFzpsxY4bjNQgNDWXs2LEcOnTogvN77bXXOH36NFOmTCkU7to1bdqUv//970X2//DDD7Rt2xZvb2/atGlTqKUGmK/bfffdR4sWLfD19SUsLIzrr7/e8X63s7e2WLFiBY888gh16tTB39+f0aNHc/LkySKvxXPPPUeDBg3w8/Nj0KBB7Ny5k+joaCZMmFDo3NTUVB566CEiIiLw9vamadOm/Oc//7lghbTFYmHq1KlkZmYWea+V9mc0Ojqaq666igULFtC1a1d8fX356KOPSrwuwI033sgvv/xS6OP569atY9++fdx4440XfLwznDlzhu+//56xY8cyZswYzpw5w48//liqx5b19+Y333zDyy+/TKNGjfDx8WHw4MHs37+/yLgff/wxTZo0wdfXl+7du7Ns2TKnPNfyOHDgAI0aNSoS7sLZ31nlsWLFCuLj4xk7dixjx45l6dKlHD58uCJTFRERuaSpgldERKSa8/Dw4OOPP6Z37968+OKL1K1bl40bN/Lrr78SFxdHnz59aNiwIf/85z/
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",
2023-08-27 15:16:52 -07:00
"What date is today? Plot a chart of META and TESLA stock price change YTD 2023\n",
2023-07-28 21:17:51 -07:00
"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-08-27 15:16:52 -07:00
"First, let's get the current date. We can use Python's built-in datetime module for this. Here is the Python code to get the current date:\n",
"\n",
"```python\n",
"# python code\n",
"import datetime\n",
"\n",
"# Get the current date\n",
"current_date = datetime.date.today()\n",
"\n",
"print(\"Today's date is:\", current_date)\n",
"```\n",
"\n",
"Next, we need to plot a chart of META (Facebook's new name) and TESLA stock price change Year-To-Date (YTD) for the year 2023. However, as of now, we are not in the year 2023 yet, so we cannot get the YTD data for 2023. \n",
"\n",
"But, we can plot the YTD stock price change for the current year. We can use the yfinance module in Python to get the stock price data. If yfinance is not installed, it can be installed using pip:\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"```sh\n",
2023-08-27 15:16:52 -07:00
"# sh code\n",
2023-07-31 19:22:30 -07:00
"pip install yfinance\n",
2023-07-28 21:17:51 -07:00
"```\n",
"\n",
2023-08-27 15:16:52 -07:00
"After installing yfinance, we can use the following Python code to get the YTD stock price data for META and TESLA and plot it:\n",
2023-07-28 21:17:51 -07:00
"\n",
"```python\n",
2023-08-27 15:16:52 -07:00
"# python code\n",
2023-07-28 21:17:51 -07:00
"import yfinance as yf\n",
"import matplotlib.pyplot as plt\n",
"\n",
2023-08-27 15:16:52 -07:00
"# Get the current year\n",
"current_year = datetime.date.today().year\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"# Get the YTD stock price data for META and TESLA\n",
"meta_data = yf.download('FB', start=f'{current_year}-01-01', end=f'{current_year}-12-31')\n",
"tesla_data = yf.download('TSLA', start=f'{current_year}-01-01', end=f'{current_year}-12-31')\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"# Plot the stock price data\n",
"plt.figure(figsize=(14, 7))\n",
"plt.plot(meta_data['Close'], label='META')\n",
"plt.plot(tesla_data['Close'], label='TESLA')\n",
"plt.title('META vs TESLA Stock Price YTD')\n",
2023-07-28 21:17:51 -07:00
"plt.xlabel('Date')\n",
2023-08-27 15:16:52 -07:00
"plt.ylabel('Price (USD)')\n",
2023-07-31 19:22:30 -07:00
"plt.legend()\n",
2023-08-27 15:16:52 -07:00
"plt.grid(True)\n",
2023-07-28 21:17:51 -07:00
"plt.show()\n",
"```\n",
"\n",
2023-08-27 15:16:52 -07:00
"Please note that the stock price data might not be available for the entire current year, depending on the current date. The code will plot the data available till the current date.\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"--------------------------------------------------------------------------------\n",
"\u001b[31m\n",
2023-08-27 15:16:52 -07:00
">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n",
"\u001b[31m\n",
">>>>>>>> EXECUTING CODE BLOCK 1 (inferred language is sh)...\u001b[0m\n"
]
},
{
"ename": "SyntaxError",
"evalue": "invalid syntax (2367222363.py, line 2)",
"output_type": "error",
"traceback": [
"\u001b[0;36m Cell \u001b[0;32mIn[7], line 2\u001b[0;36m\u001b[0m\n\u001b[0;31m pip install yfinance\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\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",
2023-08-27 15:16:52 -07:00
">>>>>>>> EXECUTING CODE BLOCK 2 (inferred language is python)...\u001b[0m\n"
2023-07-28 21:17:51 -07:00
]
},
{
"data": {
2023-08-27 15:16:52 -07:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABJEAAAJwCAYAAAA5hvCvAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAADPMklEQVR4nOzdd3xUVfrH8c+k9wAJIfQqHQQRaVKliiD2rtgLrLru+nPtIKvuurqKih1hVRAbqKCUgEhHmqAUaYbeWwKE1Lm/P04mISQhbWbuJPm+X6+87pl7z733mcyl5Mk5z3FYlmUhIiIiIiIiIiJyHn52ByAiIiIiIiIiIr5PSSQRERERERERESmSkkgiIiIiIiIiIlIkJZFERERERERERKRISiKJiIiIiIiIiEiRlEQSEREREREREZEiKYkkIiIiIiIiIiJFUhJJRERERERERESKpCSSiIiIiIiIiIgUSUkkEREREQFg+PDhRERE2Hb/Xr160atXL9vuLyIiIuenJJKIiIgXTZw4EYfDgcPhYPHixfmOW5ZF3bp1cTgcXHHFFXmOuc4r6OuBBx7g559/Pm+fs7/Odv311+NwOHjiiSc8+t6Lq1evXsV6D6NGjQKgQYMGhfYZOHBgnmsvXryYQYMGUbt2bUJCQqhXrx5Dhgxh8uTJefo5HA5GjhxZ7JjfeecdHA4HnTp1KtF7dTqdfPLJJ3Tq1Ilq1aoRGRlJ06ZNuf3221m+fHlOv40bNzJq1Ch27NhRout706hRo/J878PCwmjZsiXPPPMMycnJdoeXT0ZGBm3atKFx48acOXMm3/EdO3YQFhbGddddV+w/Vz///DM7duzIsy8wMJDY2Fi6du3KU089xa5du2x4tyIiIu4RYHcAIiIilVFISAiTJ0/m0ksvzbN/wYIF7Nmzh+Dg4ALP69evH7fffnu+/U2bNqV+/fp8+umnefY/+eSTRERE8PTTTxd4veTkZKZPn06DBg34/PPP+de//pUvyeRtTz/9NPfcc0/O65UrV/Lmm2/y1FNP0aJFi5z9bdu2zWm3a9eOv/3tb/muVatWrZz2V199xQ033EC7du145JFHqFq1KomJiSxcuJAPP/yQm2++udQxT5o0iQYNGrBixQq2bdtGkyZNinXeww8/zLhx47jyyiu55ZZbCAgIYPPmzcycOZNGjRrRuXNnwCSRRo8eTa9evWjQoEGp4/SGd999l4iICE6dOsWcOXN48cUX+emnn1iyZEmRz9acOXO8FCUEBgbywQcf0K1bN8aMGcNLL72U5/jIkSMJCgrizTff5Morr8xz7JNPPiEhISHfn7cWLVrkJKRuuukmLr/8cpxOJ8ePH2flypW88cYbjB07lvHjx3PjjTd69g2KiIh4giUiIiJeM2HCBAuwrr76ais2NtbKyMjIc/zee++1OnToYNWvX98aPHhwnmOANWLEiBLdr1WrVlbPnj0LPf7xxx9bgYGB1k8//WQB1s8//1yi63vDV199ZQHW/PnzCzxe0PeqIC1btrRatWplpaWl5Tt28ODBPK9L8r3+888/LcCaOnWqVb16dWvUqFHFOu/AgQOWw+Gw7r333nzHnE5nnpiK+h64yx133GGFh4eX6tznn3/eAqzDhw/n2X/11VdbgLV06dJCzz19+nSp7ukODz74oBUYGGitX78+Z9/XX39tAdY777xT4DkjRoywCvtvdGJiogVY//nPf/Id27Fjh9W0aVMrKCjIWrt2rXvegIiIiBdpOpuIiIgNbrrpJo4ePUpCQkLOvvT0dL7++usyjYgpqUmTJtGvXz969+5NixYtmDRpUpHnZGRkUK1aNe688858x5KTkwkJCeHvf/97zr633nqLVq1aERYWRtWqVbn44ovzTR/zhu3bt9OxY0eCgoLyHYuLiyv1dSdNmkTVqlUZPHgw1157bbG+hwCJiYlYlkW3bt3yHXM4HDkxTZw4keuuuw6A3r1755k65fLOO+/QqlUrgoODqVWrFiNGjODEiRP5rvvLL79w+eWXU7VqVcLDw2nbti1jx449b5xr166levXq9OrVi1OnThXrvZ2tT58+Oe8XzHTF1q1bs3r1anr06EFYWBhPPfVUzrFzayKlpqYyatQomjZtSkhICDVr1uTqq69m+/btOX2cTidvvPEGrVq1IiQkhBo1anD//fdz/PjxIuN7+eWXiY2N5YEHHsCyLE6dOsWjjz5Kly5deOCBB0r8fs+nfv36TJw4kfT0dF555RW3XltERMQblEQSERGxQYMGDejSpQuff/55zr6ZM2eSlJR03mkuqampHDlyJN9Xenp6iWPYt28f8+fP56abbgJMYuvrr78u8lqBgYFcddVVfPvtt/n6fvvtt6SlpeW8hw8//JCHH36Yli1b8sYbbzB69GjatWvHL7/8UuJ4zycjI6PA78vZtW7q16/PvHnz2LNnj1vvPWnSJK6++mqCgoK46aab2Lp1KytXrizyvPr16wNmml1KSkqh/Xr06MHDDz8MwFNPPcWnn37Kp59+mjO1b9SoUYwYMYJatWrx2muvcc011/D+++/Tv39/MjIycq6TkJBAjx492LhxI4888givvfYavXv3ZsaMGYXee+XKlfTp04f27dszc+bMUhXddiV7YmJicvYdPXqUQYMG0a5dO9544w169+5d4LlZWVlcccUVjB49mg4dOvDaa6/xyCOPkJSUxPr163P63X///Tz++ON069aNsWPHcueddzJp0iQGDBiQ53tQkOjoaN58800WL17MRx99xLPPPsvBgwf54IMPPDK1s0uXLjRu3DhPAllERKTcsHsolIiISGXims62cuVK6+2337YiIyOtlJQUy7Is67rrrrN69+5tWVbBU7SAQr8+//zzAu93vulsr776qhUaGmolJydblmVZW7ZssQBr2rRpRb6P2bNnW4A1ffr0PPsvv/xyq1GjRjmvr7zySqtVq1ZFXu98ijOdrbDvy8svv5zTb/z48RZgBQUFWb1797aeffZZa9GiRVZWVla+a1LM6WyrVq2yACshIcGyLDMNrU6dOtYjjzxSrPd2++23W4BVtWpV66qrrrJeffVVa9OmTcX+Hhw6dMgKCgqy+vfvn+d9vP322xZgffzxx5ZlWVZmZqbVsGFDq379+tbx48fzXMPpdOa0z57OtnjxYisqKsoaPHiwlZqaWuR7cU1n27x5s3X48GErMTHRev/9963g4GCrRo0aOVPWevbsaQHWe++9l+8aPXv2zPO8fvzxxxZg/fe//83X1xX3okWLLMCaNGlSnuOzZs0qcH9hrrjiCis6Otry9/e3nnzyyfP2Le10Npcrr7zSAqykpKRixSYiIuIrNBJJRETEJtdffz1nzpxhxowZnDx5khkzZhQ5le3KK68kISEh31dhIznOZ9KkSQwePJjIyEgALrjgAjp06FCs6Vh9+vQhNjaWL774Imff8ePHSUhI4IYbbsjZV6VKFfbs2VOskTll0alTpwK/L65RVgB33XUXs2bNolevXixevJgxY8bQvXt3LrjgApYuXVqq+06aNIkaNWrkfP8dDgc33HADU6ZMISsrq8jzJ0yYwNtvv03Dhg2ZNm0af//732nRogWXXXYZe/fuLfL8uXPnkp6ezqOPPoqfX+5/6+69916ioqL44YcfAPj1119JTEzk0UcfpUqVKnmuUdBom/nz5zNgwAAuu+wypk6dWmih94I0a9aM6tWr07BhQ+6//36aNGnCDz/8QFhYWE6f4ODgAqdDnuubb74hNjaWv/zlL/mOueL+6quviI6Opl+/fnlGoXXo0IGIiAjmz59frLjHjRtHeno6devW5dlnny3muy0d14iukydPevQ+IiIi7qbV2URERGxSvXp1+vbty+TJk0lJSSErK4trr732vOfUqVOHvn37lvnemzZt4tdff+X2229n27ZtOft79erFuHHjSE5OJioqqtDzAwICuOaaa5g8eTJpaWkEBwczdepUMjIy8iSRnnjiCebOncsll1xCkyZN6N+/PzfffHOBdYDKIjY2tljflwEDBjBgwABSUlJYvXo1X3zxBe+99x5XXHEFf/zxR4l
2023-07-28 21:17:51 -07:00
"text/plain": [
2023-08-27 15:16:52 -07:00
"<Figure size 1400x700 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-08-27 15:16:52 -07:00
"Today's date is: 2023-08-27\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-07-31 19:22:30 -07:00
"\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",
2023-08-27 15:16:52 -07:00
"It seems like there was an issue with downloading the data for the 'FB' ticker symbol. This could be due to the fact that Facebook has changed its ticker symbol to 'META' recently. Let's try to download the data using the new ticker symbol 'META'. Here is the updated Python code:\n",
2023-07-28 21:17:51 -07:00
"\n",
"```python\n",
2023-08-27 15:16:52 -07:00
"# python code\n",
2023-07-28 21:17:51 -07:00
"import yfinance as yf\n",
2023-07-31 19:22:30 -07:00
"import matplotlib.pyplot as plt\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"# Get the current year\n",
"current_year = datetime.date.today().year\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"# Get the YTD stock price data for META and TESLA\n",
"meta_data = yf.download('META', start=f'{current_year}-01-01', end=f'{current_year}-12-31')\n",
"tesla_data = yf.download('TSLA', start=f'{current_year}-01-01', end=f'{current_year}-12-31')\n",
2023-07-28 21:17:51 -07:00
"\n",
2023-08-27 15:16:52 -07:00
"# Plot the stock price data\n",
"plt.figure(figsize=(14, 7))\n",
"plt.plot(meta_data['Close'], label='META')\n",
"plt.plot(tesla_data['Close'], label='TESLA')\n",
"plt.title('META vs TESLA Stock Price YTD')\n",
2023-07-31 19:22:30 -07:00
"plt.xlabel('Date')\n",
2023-08-27 15:16:52 -07:00
"plt.ylabel('Price (USD)')\n",
2023-07-31 19:22:30 -07:00
"plt.legend()\n",
2023-08-27 15:16:52 -07:00
"plt.grid(True)\n",
2023-07-31 19:22:30 -07:00
"plt.show()\n",
2023-07-28 21:17:51 -07:00
"```\n",
"\n",
2023-08-27 15:16:52 -07:00
"Please run this code to get the YTD stock price data for META and TESLA and plot it.\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-08-27 15:16:52 -07:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABJEAAAJwCAYAAAA5hvCvAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3hUZdrH8e+k94QkQChJSOihN+lVioqIBcWKuOpacNe+u+oWXdd1X9117R3FgqgouoqignTpvfcUSiCEkIT0ycx5/ziZQEwgbUoCv8915Ton55x5zj2Zg5Kb+7kfi2EYBiIiIiIiIiIiIufg5ekARERERERERESk4VMSSUREREREREREqqUkkoiIiIiIiIiIVEtJJBERERERERERqZaSSCIiIiIiIiIiUi0lkUREREREREREpFpKIomIiIiIiIiISLWURBIRERERERERkWopiSQiIiIiIiIiItVSEklEREREAJg6dSohISEeu/+IESMYMWKEx+4vIiIi56YkkoiIiBvNmDEDi8WCxWJh+fLllc4bhkFsbCwWi4XLL7+8wjnH66r6uvvuu1m8ePE5rznz60zXXXcdFouFP/7xjy597zU1YsSIGr2HJ598EoA2bdqc9ZpLLrmkwtjLly/n0ksvpVWrVgQEBBAXF8eECRP45JNPKlxnsVi47777ahzz66+/jsVioX///rV6r3a7nQ8//JD+/fsTGRlJaGgoHTp0YMqUKaxatar8uh07dvDkk0+SkpJSq/Hd6cknn6zwsw8KCiIpKYk///nP5Obmejq8SqxWK926daNt27YUFhZWOp+SkkJQUBDXXnttjf9cLV68mJSUlArHfH19iY6OZtCgQTz++OOkpaV54N2KiIg4h4+nAxAREbkQBQQE8MknnzBkyJAKx5csWcKhQ4fw9/ev8nVjxoxhypQplY536NCB+Ph4PvroowrHH3vsMUJCQnjiiSeqHC83N5dvv/2WNm3aMGvWLP71r39VSjK52xNPPMEdd9xR/v3atWt5+eWXefzxx+ncuXP58e7du5fv9+zZk4cffrjSWC1btizfnz17NpMnT6Znz57cf//9NGnShOTkZJYuXco777zDjTfeWOeYZ86cSZs2bVizZg379u2jXbt2NXrd73//e1577TUmTpzITTfdhI+PD7t372bevHkkJiYyYMAAwEwiPfXUU4wYMYI2bdrUOU53eOONNwgJCSEvL4+ffvqJZ555hoULF/LLL79U+2z99NNPbooSfH19efvttxk8eDBPP/00//znPyucv++++/Dz8+Pll19m4sSJFc59+OGHzJ8/v9Kft86dO5cnpG644QYuu+wy7HY7J0+eZO3atbz44ou89NJLTJ8+neuvv961b1BERMQVDBEREXGb999/3wCMq6++2oiOjjasVmuF83feeafRp08fIz4+3hg/fnyFc4Axbdq0Wt2vS5cuxvDhw896/r333jN8fX2NhQsXGoCxePHiWo3vDrNnzzYAY9GiRVWer+pnVZWkpCSjS5cuRnFxcaVzx44dq/B9bX7WBw4cMABjzpw5RtOmTY0nn3yyRq87evSoYbFYjDvvvLPSObvdXiGm6n4GznLrrbcawcHBdXrt3/72NwMwjh8/XuH41VdfbQDGihUrzvra/Pz8Ot3TGe655x7D19fX2LZtW/mxL774wgCM119/vcrXTJs2zTjbX6OTk5MNwHj++ecrnUtJSTE6dOhg+Pn5GZs2bXLOGxAREXEjTWcTERHxgBtuuIETJ04wf/788mMlJSV88cUX9aqIqa2ZM2cyZswYRo4cSefOnZk5c2a1r7FarURGRnLbbbdVOpebm0tAQACPPPJI+bFXXnmFLl26EBQURJMmTejbt2+l6WPusH//fvr164efn1+lc82aNavzuDNnzqRJkyaMHz+eSZMm1ehnCJCcnIxhGAwePLjSOYvFUh7TjBkzuPbaawEYOXJkhalTDq+//jpdunTB39+fli1bMm3aNLKzsyuNu3r1ai677DKaNGlCcHAw3bt356WXXjpnnJs2baJp06aMGDGCvLy8Gr23M40aNar8/YI5XbFr166sX7+eYcOGERQUxOOPP15+7tc9kYqKinjyySfp0KEDAQEBtGjRgquvvpr9+/eXX2O323nxxRfp0qULAQEBNG/enLvuuouTJ09WG9+zzz5LdHQ0d999N4ZhkJeXxwMPPMDAgQO5++67a/1+zyU+Pp4ZM2ZQUlLCc88959SxRURE3EFJJBEREQ9o06YNAwcOZNasWeXH5s2bR05OzjmnuRQVFZGZmVnpq6SkpNYxHDlyhEWLFnHDDTcAZmLriy++qHYsX19frrrqKr7++utK13799dcUFxeXv4d33nmH3//+9yQlJfHiiy/y1FNP0bNnT1avXl3reM/FarVW+XM5s9dNfHw8P//8M4cOHXLqvWfOnMnVV1+Nn58fN9xwA3v37mXt2rXVvi4+Ph4wp9kVFBSc9bphw4bx+9//HoDHH3+cjz76iI8++qh8at+TTz7JtGnTaNmyJf/5z3+45ppreOuttxg7dixWq7V8nPnz5zNs2DB27NjB/fffz3/+8x9GjhzJ3Llzz3rvtWvXMmrUKHr16sW8efPq1HTbkeyJiooqP3bixAkuvfRSevbsyYsvvsjIkSOrfK3NZuPyyy/nqaeeok+fPvznP//h/vvvJycnh23btpVfd9ddd/Hoo48yePBgXnrpJW677TZmzpzJuHHjKvwMqhIeHs7LL7/M8uXLeffdd/nLX/7CsWPHePvtt10ytXPgwIG0bdu2QgJZRESk0fB0KZSIiMiFxDGdbe3atcarr75qhIaGGgUFBYZhGMa1115rjBw50jCMqqdoAWf9mjVrVpX3O9d0tn//+99GYGCgkZubaxiGYezZs8cAjK+++qra9/Hjjz8agPHtt99WOH7ZZZcZiYmJ5d9PnDjR6NKlS7XjnUtNprOd7efy7LPPll83ffp0AzD8/PyMkSNHGn/5y1+MZcuWGTabrdKY1HA627p16wzAmD9/vmEY5jS01q1bG/fff3+N3tuUKVMMwGjSpIlx1VVXGf/+97+NnTt31vhnkJGRYfj5+Rljx46t8D5effVVAzDee+89wzAMo7S01EhISDDi4+ONkydPVhjDbreX7585nW358uVGWFiYMX78eKOoqKja9+KYzrZ7927j+PHjRnJysvHWW28Z/v7+RvPmzcunrA0fPtwAjDfffLPSGMOHD6/wvL733nsGYLzwwguVrnXEvWzZMgMwZs6cWeH8Dz/8UOXxs7n88suN8PBww9vb23jsscfOeW1dp7M5TJw40QCMnJycGsUmIiLSUKgSSURExEOuu+46CgsLmTt3LqdOnWLu3LnVTmWbOHEi8+fPr/R1tkqOc5k5cybjx48nNDQUgPbt29OnT58aTccaNWoU0dHRfPbZZ+XHTp48yfz585k8eXL5sYiICA4dOlSjypz66N+/f5U/F0eVFcBvfvMbfvjhB0aMGMHy5ct5+umnGTp0KO3bt2fFihV1uu/MmTNp3rx5+c/fYrEwefJkPv30U2w2W7Wvf//993n11VdJSEjgq6++4pFHHqFz585cfPHFHD58uNrXL1iwgJKSEh544AG8vE7/te7OO+8kLCyM7777DoCNGzeSnJzMAw88QERERIUxqqq2WbRoEePGjePiiy9mzpw5Z230XpWOHTvStGlTEhISuOuuu2jXrh3fffcdQUFB5df4+/tXOR3y17788kuio6P53e9+V+mcI+7Zs2cTHh7OmDFjKlSh9enTh5CQEBYtWlSjuF977TVKSkqIjY3lL3/5Sw3fbd04KrpOnTrl0vuIiIg4m1ZnExER8ZCmTZsyevRoPvnkEwoKCrDZbEyaNOmcr2ndujWjR4+u97137tzJxo0bmTJlCvv27Ss/PmLECF577TVyc3MJCws76+t9fHy45ppr+OSTTyguLsbf3585c+ZgtVorJJH++Mc/smDBAi666CLatWvH2LFjufHGG6vsA1Qf0dHRNfq5jBs3jnHjxlFQUMD69ev57LPPePPNN7n88svZtWtXrXo
2023-07-28 21:17:51 -07:00
"text/plain": [
2023-08-27 15:16:52 -07:00
"<Figure size 1400x700 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-08-27 15:16:52 -07:00
"Great! The code has executed successfully. It should have downloaded the Year-To-Date (YTD) stock price data for META and TESLA for the current year and plotted it. The plot should show the closing prices of META and TESLA stocks over time. \n",
"\n",
"Please check the plot to see the stock price changes. If the plot is as expected, then the task is completed.\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",
"# the assistant receives a message from the user, which contains the task description\n",
"ipy_user.initiate_chat(\n",
" assistant,\n",
2023-08-27 15:16:52 -07:00
" message=\"\"\"What date is today? Plot a chart of META and TESLA stock price change YTD 2023\"\"\",\n",
2023-07-28 21:17:51 -07:00
")"
]
}
],
"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-27 15:16:52 -07:00
"version": "3.9.17"
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
}