2023-05-27 23:17:23 -04:00
{
"cells": [
2023-06-09 11:40:04 -07:00
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"<a href=\"https://colab.research.google.com/github/microsoft/FLAML/blob/main/notebook/autogen_agent_auto_feedback_from_code_execution.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
2023-05-27 23:17:23 -04:00
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
2023-06-09 11:40:04 -07:00
"# Interactive LLM Agent with Auto Feedback from Code Execution\n",
2023-05-27 23:17:23 -04:00
"\n",
2023-06-09 11:40:04 -07:00
"FLAML offers an experimental feature of interactive 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-05-27 23:17:23 -04:00
"\n",
2023-06-09 11:40:04 -07:00
"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 uses auto-feedback based on the result of code execution. For example, when `human_input_mode` is set to \"ALWAYS\", the `UserProxyAgent` will always prompt the user for feedback. When user feedback is provided, the `UserProxyAgent` will directly pass the feedback to `AssistantAgent` without doing any additional steps. When no user feedback is provided, the `UserProxyAgent` will execute the code written by `AssistantAgent` directly and return the execution results (success or failure and corresponding outputs) to `AssistantAgent`.\n",
2023-05-27 23:17:23 -04:00
"\n",
"## Requirements\n",
"\n",
2023-07-08 22:25:43 -07:00
"FLAML requires `Python>=3.8`. To run this notebook example, please install flaml with the [autogen] option:\n",
2023-05-27 23:17:23 -04:00
"```bash\n",
"pip install flaml[autogen]\n",
"```"
]
},
{
"cell_type": "code",
2023-06-09 11:40:04 -07:00
"execution_count": 1,
2023-05-27 23:17:23 -04:00
"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-07-08 22:25:43 -07:00
"# %pip install flaml[autogen]==2.0.0rc3"
2023-05-27 23:17:23 -04:00
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set your API Endpoint\n",
"\n",
2023-07-04 13:29:32 -07:00
"The [`config_list_from_models`](https://microsoft.github.io/FLAML/docs/reference/autogen/oai/openai_utils#config_list_from_models) function tries to create a list of configurations using Azure OpenAI endpoints and OpenAI endpoints for the provided list of models. It assumes the api keys and api bases are stored in the corresponding environment variables or local txt files:\n",
2023-05-27 23:17:23 -04:00
"\n",
"- OpenAI API key: os.environ[\"OPENAI_API_KEY\"] or `openai_api_key_file=\"key_openai.txt\"`.\n",
"- Azure OpenAI API key: os.environ[\"AZURE_OPENAI_API_KEY\"] or `aoai_api_key_file=\"key_aoai.txt\"`. Multiple keys can be stored, one per line.\n",
"- Azure OpenAI API base: os.environ[\"AZURE_OPENAI_API_BASE\"] or `aoai_api_base_file=\"base_aoai.txt\"`. Multiple bases can be stored, one per line.\n",
"\n",
2023-06-09 11:40:04 -07:00
"It's OK to have only the OpenAI API key, or only the Azure OpenAI API key + base.\n"
2023-05-27 23:17:23 -04:00
]
},
{
"cell_type": "code",
2023-06-09 11:40:04 -07:00
"execution_count": 2,
2023-05-27 23:17:23 -04:00
"metadata": {},
"outputs": [],
"source": [
"from flaml import oai\n",
"\n",
2023-06-09 11:40:04 -07:00
"config_list = oai.config_list_from_models(model_list=[\"gpt-4\"])"
2023-05-27 23:17:23 -04:00
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
2023-06-09 11:40:04 -07:00
"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",
" }, # only if OpenAI API key is found\n",
" {\n",
" 'model': 'gpt-4',\n",
" 'api_key': '<your first Azure OpenAI API key here>',\n",
" 'api_base': '<your first Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-03-15-preview',\n",
" }, # only if the at least one Azure OpenAI API key is found\n",
" {\n",
" 'model': 'gpt-4',\n",
" 'api_key': '<your second Azure OpenAI API key here>',\n",
" 'api_base': '<your second Azure OpenAI API base here>',\n",
" 'api_type': 'azure',\n",
" 'api_version': '2023-03-15-preview',\n",
" }, # only if the second Azure OpenAI API key is found\n",
"]\n",
"```\n",
2023-05-27 23:17:23 -04:00
"\n",
2023-06-09 11:40:04 -07:00
"You can directly override it if the above function returns an empty list, i.e., it doesn't find the keys in the specified locations."
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
2023-07-14 15:52:45 -07:00
"## Example Task: Check Stock Price Change\n",
2023-06-09 11:40:04 -07:00
"\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."
2023-05-27 23:17:23 -04:00
]
},
{
"cell_type": "code",
2023-06-09 11:40:04 -07:00
"execution_count": 3,
2023-05-27 23:17:23 -04:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-06-09 11:40:04 -07:00
"user (to assistant):\n",
2023-05-27 23:17:23 -04:00
"\n",
2023-07-14 15:52:45 -07:00
"What date is today? Compare the year-to-date gain for META and TESLA.\n",
2023-05-27 23:17:23 -04:00
"\n",
2023-07-10 09:07:48 -07:00
"--------------------------------------------------------------------------------\n",
2023-06-09 11:40:04 -07:00
"assistant (to user):\n",
2023-07-08 22:25:43 -07:00
"\n",
2023-07-14 15:52:45 -07:00
"To get the current date and compare the year-to-date gain for META and TESLA, we can use the `datetime` and `yfinance` libraries in Python. The `yfinance` library allows us to download stock market data from Yahoo Finance.\n",
2023-07-10 09:07:48 -07:00
"\n",
2023-07-14 15:52:45 -07:00
"Here is the Python code to do this:\n",
2023-07-10 09:07:48 -07:00
"\n",
2023-07-14 15:52:45 -07:00
"```python\n",
"# filename: stock_comparison.py\n",
2023-07-10 09:07:48 -07:00
"\n",
2023-07-14 15:52:45 -07:00
"import datetime\n",
"import yfinance as yf\n",
2023-07-10 09:07:48 -07:00
"\n",
2023-07-14 15:52:45 -07:00
"# Get today's date\n",
"today = datetime.date.today()\n",
"print(\"Today's date:\", today)\n",
2023-07-10 09:07:48 -07:00
"\n",
2023-07-14 15:52:45 -07:00
"# Get the data for the stock META and TESLA\n",
"meta = yf.Ticker(\"META\")\n",
"tesla = yf.Ticker(\"TSLA\")\n",
2023-05-27 23:17:23 -04:00
"\n",
2023-07-14 15:52:45 -07:00
"# Get the historical data for this year\n",
"meta_data = meta.history(start=f'{today.year}-01-01', end=str(today))\n",
"tesla_data = tesla.history(start=f'{today.year}-01-01', end=str(today))\n",
2023-07-10 09:07:48 -07:00
"\n",
2023-07-14 15:52:45 -07:00
"# Calculate the year-to-date gain for each stock\n",
"meta_gain = (meta_data['Close'][-1] - meta_data['Close'][0]) / meta_data['Close'][0]\n",
"tesla_gain = (tesla_data['Close'][-1] - tesla_data['Close'][0]) / tesla_data['Close'][0]\n",
2023-07-10 09:07:48 -07:00
"\n",
2023-07-14 15:52:45 -07:00
"print(f\"Year-to-date gain for META: {meta_gain * 100}%\")\n",
"print(f\"Year-to-date gain for TESLA: {tesla_gain * 100}%\")\n",
2023-07-10 09:07:48 -07:00
"```\n",
"\n",
2023-07-14 15:52:45 -07:00
"You can save this code in a file named `stock_comparison.py` and run it using Python.\n",
2023-07-10 09:07:48 -07:00
"\n",
"--------------------------------------------------------------------------------\n",
"\n",
">>>>>>>> NO HUMAN INPUT RECEIVED. USING AUTO REPLY FOR THE USER...\n",
"user (to assistant):\n",
"\n",
2023-07-14 15:52:45 -07:00
"exitcode: 0 (execution succeeded)\n",
2023-07-10 09:07:48 -07:00
"Code output: \n",
2023-07-14 15:52:45 -07:00
"Today's date: 2023-07-12\n",
"Year-to-date gain for META: 139.12940007477712%\n",
"Year-to-date gain for TESLA: 149.5744795126052%\n",
2023-05-27 23:17:23 -04:00
"\n",
"\n",
2023-07-08 22:25:43 -07:00
"--------------------------------------------------------------------------------\n",
2023-06-09 11:40:04 -07:00
"assistant (to user):\n",
"\n",
2023-07-14 15:52:45 -07:00
"Great! The code executed successfully. Today's date is July 12, 2023. The year-to-date gain for META is approximately 139.13%, and the year-to-date gain for TESLA is approximately 149.57%. \n",
2023-07-10 09:07:48 -07:00
"\n",
2023-07-14 15:52:45 -07:00
"If you have any other questions or need further assistance, feel free to ask.\n",
2023-07-08 22:25:43 -07:00
"\n",
"TERMINATE\n",
2023-05-27 23:17:23 -04:00
"\n",
2023-07-08 22:25:43 -07:00
"--------------------------------------------------------------------------------\n"
2023-05-27 23:17:23 -04:00
]
}
],
"source": [
2023-06-09 11:40:04 -07:00
"from flaml.autogen.agent import AssistantAgent, UserProxyAgent\n",
2023-05-27 23:17:23 -04:00
"\n",
2023-06-09 11:40:04 -07:00
"# create an AssistantAgent named \"assistant\"\n",
2023-07-14 15:52:45 -07:00
"assistant = AssistantAgent(\n",
" \"assistant\",\n",
" seed=42,\n",
" config_list=config_list,\n",
" temperature=0,\n",
")\n",
2023-05-27 23:17:23 -04:00
"# create a UserProxyAgent instance named \"user\"\n",
"user = UserProxyAgent(\n",
" \"user\",\n",
" human_input_mode=\"NEVER\",\n",
" max_consecutive_auto_reply=10,\n",
2023-07-06 06:08:44 +08:00
" is_termination_msg=lambda x: x.get(\"content\", \"\").rstrip().endswith(\"TERMINATE\") or x.get(\"content\", \"\").rstrip().endswith('\"TERMINATE\".'),\n",
2023-06-09 11:40:04 -07:00
" work_dir=\"coding\",\n",
" use_docker=False, # set to True if you are using docker\n",
2023-05-27 23:17:23 -04:00
")\n",
"# the assistant receives a message from the user, which contains the task description\n",
"assistant.receive(\n",
2023-07-14 15:52:45 -07:00
" \"\"\"What date is today? Compare the year-to-date gain for META and TESLA.\"\"\",\n",
2023-05-27 23:17:23 -04:00
" user,\n",
")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
2023-07-14 15:52:45 -07:00
"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"
2023-05-27 23:17:23 -04:00
]
},
{
2023-07-14 15:52:45 -07:00
"attachments": {},
"cell_type": "markdown",
2023-05-27 23:17:23 -04:00
"metadata": {},
"source": [
2023-07-14 15:52:45 -07:00
"All the feedback is auto generated."
2023-05-27 23:17:23 -04:00
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
2023-07-14 15:52:45 -07:00
"## Example Task: Plot Chart"
2023-05-27 23:17:23 -04:00
]
},
{
"cell_type": "code",
2023-07-14 15:52:45 -07:00
"execution_count": 4,
2023-05-27 23:17:23 -04:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2023-06-09 11:40:04 -07:00
"user (to assistant):\n",
2023-05-27 23:17:23 -04:00
"\n",
2023-07-14 15:52:45 -07:00
"Plot a chart of their stock price change YTD and save to stock_price_ytd.png.\n",
2023-05-27 23:17:23 -04:00
"\n",
2023-07-08 22:25:43 -07:00
"--------------------------------------------------------------------------------\n",
2023-06-09 11:40:04 -07:00
"assistant (to user):\n",
2023-07-08 22:25:43 -07:00
"\n",
2023-07-14 15:52:45 -07:00
"To plot a chart of the stock price change year-to-date (YTD) 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-05-27 23:17:23 -04:00
"\n",
2023-06-09 11:40:04 -07:00
"```python\n",
2023-07-14 15:52:45 -07:00
"# filename: stock_price_plot.py\n",
"\n",
2023-07-10 09:07:48 -07:00
"import datetime\n",
2023-06-09 11:40:04 -07:00
"import yfinance as yf\n",
2023-07-14 15:52:45 -07:00
"import matplotlib.pyplot as plt\n",
"\n",
"# Get today's date\n",
"today = datetime.date.today()\n",
"\n",
"# Get the data for the stock META and TESLA\n",
"meta = yf.Ticker(\"META\")\n",
"tesla = yf.Ticker(\"TSLA\")\n",
"\n",
"# Get the historical data for this year\n",
"meta_data = meta.history(start=f'{today.year}-01-01', end=str(today))\n",
"tesla_data = tesla.history(start=f'{today.year}-01-01', end=str(today))\n",
"\n",
"# Plot the closing price of META and TESLA\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",
"plt.xlabel('Date')\n",
"plt.ylabel('Closing Price')\n",
"plt.legend()\n",
"\n",
"# Save the plot to a file\n",
"plt.savefig('stock_price_ytd.png')\n",
2023-06-09 11:40:04 -07:00
"```\n",
2023-07-14 15:52:45 -07:00
"\n",
"You can save this code in a file named `stock_price_plot.py` and run it using Python. This will create a file named `stock_price_ytd.png` in the same directory.\n",
2023-05-27 23:17:23 -04:00
"\n",
2023-07-08 22:25:43 -07:00
"--------------------------------------------------------------------------------\n",
2023-05-27 23:17:23 -04:00
"\n",
2023-07-08 22:25:43 -07:00
">>>>>>>> NO HUMAN INPUT RECEIVED. USING AUTO REPLY FOR THE USER...\n",
2023-06-09 11:40:04 -07:00
"user (to assistant):\n",
2023-07-08 22:25:43 -07:00
"\n",
2023-07-10 09:07:48 -07:00
"exitcode: 0 (execution succeeded)\n",
2023-06-09 11:40:04 -07:00
"Code output: \n",
2023-07-10 09:07:48 -07:00
"\n",
"\n",
"--------------------------------------------------------------------------------\n",
"assistant (to user):\n",
"\n",
2023-07-14 15:52:45 -07:00
"Great! The code executed successfully and should have created a file named `stock_price_ytd.png` in the same directory. This file contains a chart of the stock price change year-to-date (YTD) for META and TESLA.\n",
"\n",
"If you have any other questions or need further assistance, feel free to ask.\n",
"\n",
2023-07-10 09:07:48 -07:00
"TERMINATE\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
2023-07-14 15:52:45 -07:00
"# followup of the previous question\n",
2023-07-10 09:07:48 -07:00
"assistant.receive(\n",
2023-07-14 15:52:45 -07:00
" \"\"\"Plot a chart of their stock price change YTD and save to stock_price_ytd.png.\"\"\",\n",
" user\n",
2023-07-10 09:07:48 -07:00
")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
2023-07-14 15:52:45 -07:00
"Let's display the generated figure."
2023-07-10 09:07:48 -07:00
]
},
{
"cell_type": "code",
2023-07-14 15:52:45 -07:00
"execution_count": 5,
2023-07-10 09:07:48 -07:00
"metadata": {},
"outputs": [
{
2023-07-14 15:52:45 -07:00
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABXgAAAK8CAYAAABV1dcbAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3hUddrG8Xsy6T0hJAESQuhdivQiTUBBUGyoiKhrBfuqL1bQVVx3bbt2RbBQFIVVkCJIE5Teew01IYSQ3jPn/eOQSEwogSQnk3w/1zXXOXPqc0YEcvOb52czDMMQAAAAAAAAAMDpuFhdAAAAAAAAAADg0hDwAgAAAAAAAICTIuAFAAAAAAAAACdFwAsAAAAAAAAAToqAFwAAAAAAAACcFAEvAAAAAAAAADgpAl4AAAA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ba+TIkVq1alXhcTt27NC4ceMUExNTqutXpHHjxhX57L29vdW8eXO98MILSklJsbq8YnJzc9WqVSs1aNBAmZmZxfbHxMTI29tbN99880X/f7V06VLFxMQU2ebm5qaQkBB17dpVzz33nA4fPmzB0wIAAFw8V6sLAAAAcAaenp6aOnWqunfvXmT7smXLdPToUXl4eJR43tVXX62RI0cW2964cWNFRUXp66+/LrJ97Nix8vX11fPPP1/i9VJSUjR79mzVq1dP06ZN0xtvvFEsAK5ozz//vP72t78Vvl+7dq3+85//6LnnnlOzZs0Kt7du3bpwvU2bNnrqqaeKXat27dqF6zNmzNCtt96qNm3a6LHHHlNQUJAOHjyo5cuX67PPPtPtt99+yTVPmTJF9erV05o1a7Rv3z41bNjwos579NFH9cEHH2jo0KG644475Orqqt27d2vevHmqX7++OnfuLMkMeMePH69evXqpXr16l1xnRfjoo4/k6+urtLQ0/fLLL3rttde0ePFirVy58oK/tn755ZcKqlJyc3PTp59+qm7duunVV1/V66+/XmT/mDFj5O7urv/85z8aOnRokX1fffWVFi5cWOz/t2bNmhWGxbfddpuuvfZaORwOnT59WmvXrtW7776r9957TxMnTtTw4cPL9wEBAAAulQEAAIBzmjRpkiHJGDZsmBESEmLk5uYW2X/fffcZ7du3N6KiooxBgwYV2SfJGD16dKnu16JFC+Oqq6465/4vvvjCcHNzMxYvXmxIMpYuXVqq61eEGTNmGJKMJUuWlLi/pM+qJM2bNzdatGhhZGdnF9t34sSJIu9L81kfOHDAkGTMnDnTqFmzpjFu3LiLOi8uLs6w2WzGfffdV2yfw+EoUtOFPoOyctdddxk+Pj6XdO7LL79sSDJOnjxZZPuwYcMMScbvv/9+znPT09Mv6Z5l4aGHHjLc3NyMbdu2FW77/vvvDUnGhx9+WOI5o0ePNs71o8/BgwcNSca//vWvYvtiYmKMxo0bG+7u7samTZvK5gEAAADKGC0aAAAALsJtt92mU6dOaeHChYXbcnJy9P3331/WSNLSmjJliq6++mr17t1bzZo105QpUy54Tm5uroKDg3X33XcX25eSkiJ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4369esXvh86dKjRokWLC17vfC6mRcO5PpcJEyYUHjdx4kRDkuHu7m707t3bePHFF43ffvvNyM/PL3ZNXWSLhnXr1hmSjIULFxqGYbZWiIiIMB577LGLeraRI0cakoygoCDjhhtuMP79738bO3fuvOjPID4+3nB3dzf69+9f5Dnef/99Q5LxxRdfGIZhGHl5eUZ0dLQRFRVlnD59usg1HA5H4frZLRpWrFhh+Pv7G4MGDTKysrIu+CwFLRp2795tnDx50jh48KDxySefGB4eHkZYWFhhG4arrrrKkGR8/PHHxa5x1VVXFfn1+sUXXxiSjLfffrvYsQV1//bbb4Y
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
2023-05-27 23:17:23 -04:00
}
],
"source": [
2023-07-14 15:52:45 -07:00
"from IPython.display import Image\n",
"\n",
"Image(filename='coding/stock_price_ytd.png')"
2023-06-09 11:40:04 -07:00
]
2023-05-27 23:17:23 -04: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-07-08 22:25:43 -07:00
"version": "3.9.15"
2023-05-27 23:17:23 -04: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
}