├── README.md ├── .gitignore ├── agentchat_groupchat.ipynb ├── LICENSE └── agentchat_custom_model.ipynb /README.md: -------------------------------------------------------------------------------- 1 | # milei-gpt-groupchat 2 | Presidential bot built on top of Llama3-8B fine-tune over +300 hours of video interviews + groupchat using AutoGen multi-agent framework 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/latest/usage/project/#working-with-version-control 110 | .pdm.toml 111 | .pdm-python 112 | .pdm-build/ 113 | 114 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 115 | __pypackages__/ 116 | 117 | # Celery stuff 118 | celerybeat-schedule 119 | celerybeat.pid 120 | 121 | # SageMath parsed files 122 | *.sage.py 123 | 124 | # Environments 125 | .env 126 | .venv 127 | env/ 128 | venv/ 129 | ENV/ 130 | env.bak/ 131 | venv.bak/ 132 | 133 | # Spyder project settings 134 | .spyderproject 135 | .spyproject 136 | 137 | # Rope project settings 138 | .ropeproject 139 | 140 | # mkdocs documentation 141 | /site 142 | 143 | # mypy 144 | .mypy_cache/ 145 | .dmypy.json 146 | dmypy.json 147 | 148 | # Pyre type checker 149 | .pyre/ 150 | 151 | # pytype static type analyzer 152 | .pytype/ 153 | 154 | # Cython debug symbols 155 | cython_debug/ 156 | 157 | # PyCharm 158 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 159 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 160 | # and can be added to the global gitignore or merged into this file. For a more nuclear 161 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 162 | #.idea/ 163 | -------------------------------------------------------------------------------- /agentchat_groupchat.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# Group Chat\n", 9 | "\n", 10 | "AutoGen offers conversable agents powered by LLM, tool or human, which can be used to perform tasks collectively via automated chat. This framework allows tool use and human participation through multi-agent conversation.\n", 11 | "Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat).\n", 12 | "\n", 13 | "This notebook is modified based on https://github.com/microsoft/FLAML/blob/4ea686af5c3e8ff24d9076a7a626c8b28ab5b1d7/notebook/autogen_multiagent_roleplay_chat.ipynb\n", 14 | "\n", 15 | "````{=mdx}\n", 16 | ":::info Requirements\n", 17 | "Install `pyautogen`:\n", 18 | "```bash\n", 19 | "pip install pyautogen\n", 20 | "```\n", 21 | "\n", 22 | "For more information, please refer to the [installation guide](/docs/installation/).\n", 23 | ":::\n", 24 | "````" 25 | ] 26 | }, 27 | { 28 | "attachments": {}, 29 | "cell_type": "markdown", 30 | "metadata": {}, 31 | "source": [ 32 | "## Set your API Endpoint\n", 33 | "\n", 34 | "The [`config_list_from_json`](https://microsoft.github.io/autogen/docs/reference/oai/openai_utils#config_list_from_json) function loads a list of configurations from an environment variable or a json file." 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 106, 40 | "metadata": {}, 41 | "outputs": [], 42 | "source": [ 43 | "import autogen\n", 44 | "\n", 45 | "config_list = autogen.config_list_from_json(\n", 46 | " \"OAI_CONFIG_LIST\",\n", 47 | " filter_dict={\n", 48 | " \"model\": [\"gpt-4\", \"gpt-4-0314\", \"gpt4\", \"gpt-4-32k\", \"gpt-4-32k-0314\", \"gpt-4-32k-v0314\"],\n", 49 | " },\n", 50 | ")" 51 | ] 52 | }, 53 | { 54 | "attachments": {}, 55 | "cell_type": "markdown", 56 | "metadata": {}, 57 | "source": [ 58 | "````{=mdx}\n", 59 | ":::tip\n", 60 | "Learn more about configuring LLMs for agents [here](/docs/topics/llm_configuration).\n", 61 | ":::\n", 62 | "````\n", 63 | "\n", 64 | "## Construct Agents" 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "execution_count": 107, 70 | "metadata": {}, 71 | "outputs": [], 72 | "source": [ 73 | "llm_config = {\"config_list\": config_list, \"cache_seed\": 42}\n", 74 | "user_proxy = autogen.UserProxyAgent(\n", 75 | " name=\"User_proxy\",\n", 76 | " system_message=\"A human admin.\",\n", 77 | " code_execution_config={\n", 78 | " \"last_n_messages\": 2,\n", 79 | " \"work_dir\": \"groupchat\",\n", 80 | " \"use_docker\": False,\n", 81 | " }, # Please set use_docker=True if docker is available to run the generated code. Using docker is safer than running the generated code directly.\n", 82 | " human_input_mode=\"TERMINATE\",\n", 83 | ")\n", 84 | "coder = autogen.AssistantAgent(\n", 85 | " name=\"Coder\",\n", 86 | " llm_config=llm_config,\n", 87 | ")\n", 88 | "pm = autogen.AssistantAgent(\n", 89 | " name=\"Product_manager\",\n", 90 | " system_message=\"Creative in software product ideas.\",\n", 91 | " llm_config=llm_config,\n", 92 | ")\n", 93 | "groupchat = autogen.GroupChat(agents=[user_proxy, coder, pm], messages=[], max_round=12)\n", 94 | "manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)" 95 | ] 96 | }, 97 | { 98 | "attachments": {}, 99 | "cell_type": "markdown", 100 | "metadata": {}, 101 | "source": [ 102 | "## Start Chat" 103 | ] 104 | }, 105 | { 106 | "cell_type": "code", 107 | "execution_count": 108, 108 | "metadata": {}, 109 | "outputs": [ 110 | { 111 | "name": "stdout", 112 | "output_type": "stream", 113 | "text": [ 114 | "\u001b[33mUser_proxy\u001b[0m (to chat_manager):\n", 115 | "\n", 116 | "Find a latest paper about gpt-4 on arxiv and find its potential applications in software.\n", 117 | "\n", 118 | "--------------------------------------------------------------------------------\n", 119 | "\u001b[33mCoder\u001b[0m (to chat_manager):\n", 120 | "\n", 121 | "To find the latest paper about GPT-4 on arxiv, I'll provide you with a Python code that fetches the most recent papers from the arxiv API and filters the results to get the most relevant paper related to GPT-4. After fetching the paper, I'll extract the information for potential applications in software. Please execute the following Python code:\n", 122 | "\n", 123 | "```python\n", 124 | "import requests\n", 125 | "from bs4 import BeautifulSoup\n", 126 | "import re\n", 127 | "\n", 128 | "def fetch_arxiv_papers(query):\n", 129 | " base_url = \"http://export.arxiv.org/api/query?\"\n", 130 | " search_query = \"all:\" + query\n", 131 | " response = requests.get(base_url, params={\"search_query\": search_query, \"sortBy\": \"submittedDate\", \"sortOrder\": \"descending\"})\n", 132 | " return BeautifulSoup(response.content, \"xml\")\n", 133 | "\n", 134 | "def find_gpt4_paper():\n", 135 | " papers = fetch_arxiv_papers(\"gpt-4\")\n", 136 | " for entry in papers.find_all(\"entry\"):\n", 137 | " title = entry.title.text.strip()\n", 138 | " summary = entry.summary.text.strip()\n", 139 | " if \"gpt-4\" in title.lower() or \"gpt-4\" in summary.lower():\n", 140 | " return {\"title\": title, \"summary\": summary}\n", 141 | "\n", 142 | "gpt4_paper = find_gpt4_paper()\n", 143 | "if gpt4_paper:\n", 144 | " print(\"Title:\", gpt4_paper[\"title\"])\n", 145 | " print(\"Summary:\", gpt4_paper[\"summary\"])\n", 146 | "else:\n", 147 | " print(\"No recent GPT-4 papers found.\")\n", 148 | "```\n", 149 | "\n", 150 | "Once we have the paper details, I'll analyze the summary to identify potential applications in software development.\n", 151 | "\n", 152 | "--------------------------------------------------------------------------------\n", 153 | "\u001b[31m\n", 154 | ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", 155 | "\u001b[31m\n", 156 | ">>>>>>>> EXECUTING CODE BLOCK 0 (inferred language is python)...\u001b[0m\n", 157 | "\u001b[33mUser_proxy\u001b[0m (to chat_manager):\n", 158 | "\n", 159 | "exitcode: 0 (execution succeeded)\n", 160 | "Code output: \n", 161 | "Title: FIMO: A Challenge Formal Dataset for Automated Theorem Proving\n", 162 | "Summary: We present FIMO, an innovative dataset comprising formal mathematical problem\n", 163 | "statements sourced from the International Mathematical Olympiad (IMO)\n", 164 | "Shortlisted Problems. Designed to facilitate advanced automated theorem proving\n", 165 | "at the IMO level, FIMO is currently tailored for the Lean formal language. It\n", 166 | "comprises 149 formal problem statements, accompanied by both informal problem\n", 167 | "descriptions and their corresponding LaTeX-based informal proofs. Through\n", 168 | "initial experiments involving GPT-4, our findings underscore the existing\n", 169 | "limitations in current methodologies, indicating a substantial journey ahead\n", 170 | "before achieving satisfactory IMO-level automated theorem proving outcomes.\n", 171 | "\n", 172 | "\n", 173 | "--------------------------------------------------------------------------------\n", 174 | "\u001b[33mProduct_manager\u001b[0m (to chat_manager):\n", 175 | "\n", 176 | "Based on the paper titled \"FIMO: A Challenge Formal Dataset for Automated Theorem Proving\" and its summary, the potential applications of GPT-4 in software development can be related to the field of automated theorem proving.\n", 177 | "\n", 178 | "1. **Automated theorem proving**: GPT-4 can be utilized in the development of automated theorem proving software that attempts to prove complex mathematical problems taken from International Mathematical Olympiad (IMO) or other challenging sources. By fine-tuning GPT-4 with a dataset like FIMO consisting of formal mathematical problems, the model can potentially better understand the problem statements and generate appropriate proofs.\n", 179 | "\n", 180 | "2. **Mathematical problem-solving assistants**: Software tools can be developed using GPT-4 to guide users in solving complex mathematical problems. The AI model can be integrated into educational platforms, online math tutoring services, or even standalone tools to help make solving problems easier and faster for students and professionals alike.\n", 181 | "\n", 182 | "3. **Formal language translation**: GPT-4 can potentially be integrated into software for translating between formal languages, assisting in the understanding and comparison of various formal systems. This would be especially useful in research communities employing different formal languages and wanting to share ideas and results.\n", 183 | "\n", 184 | "4. **Mathematical proof checking**: GPT-4 can be employed in proof-checking software to identify and correct inconsistencies. By improving the correctness of proofs, this application would ultimately help users save time and contribute to the overall quality of mathematical research.\n", 185 | "\n", 186 | "Please note that this paper highlights the current limitations of GPT-4 in the context of IMO-level theorem proving. Nevertheless, these potential applications suggest directions for further research and software development as the model and related techniques continue to improve.\n", 187 | "\n", 188 | "--------------------------------------------------------------------------------\n", 189 | "\u001b[31m\n", 190 | ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", 191 | "\u001b[33mUser_proxy\u001b[0m (to chat_manager):\n", 192 | "\n", 193 | "\n", 194 | "\n", 195 | "--------------------------------------------------------------------------------\n", 196 | "\u001b[31m\n", 197 | ">>>>>>>> USING AUTO REPLY...\u001b[0m\n", 198 | "\u001b[33mUser_proxy\u001b[0m (to chat_manager):\n", 199 | "\n", 200 | "\n", 201 | "\n", 202 | "--------------------------------------------------------------------------------\n", 203 | "\u001b[33mCoder\u001b[0m (to chat_manager):\n", 204 | "\n", 205 | "TERMINATE\n", 206 | "\n", 207 | "--------------------------------------------------------------------------------\n" 208 | ] 209 | } 210 | ], 211 | "source": [ 212 | "user_proxy.initiate_chat(\n", 213 | " manager, message=\"Find a latest paper about gpt-4 on arxiv and find its potential applications in software.\"\n", 214 | ")\n", 215 | "# type exit to terminate the chat" 216 | ] 217 | } 218 | ], 219 | "metadata": { 220 | "front_matter": { 221 | "tags": ["orchestration", "group chat"], 222 | "description": "Explore the utilization of large language models in automated group chat scenarios, where agents perform tasks collectively, demonstrating how they can be configured, interact with each other, and retrieve specific information from external resources." 223 | }, 224 | "kernelspec": { 225 | "display_name": "flaml", 226 | "language": "python", 227 | "name": "python3" 228 | }, 229 | "language_info": { 230 | "codemirror_mode": { 231 | "name": "ipython", 232 | "version": 3 233 | }, 234 | "file_extension": ".py", 235 | "mimetype": "text/x-python", 236 | "name": "python", 237 | "nbconvert_exporter": "python", 238 | "pygments_lexer": "ipython3", 239 | "version": "3.9.17" 240 | }, 241 | "orig_nbformat": 4 242 | }, 243 | "nbformat": 4, 244 | "nbformat_minor": 2 245 | } 246 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /agentchat_custom_model.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": { 7 | "slideshow": { 8 | "slide_type": "slide" 9 | } 10 | }, 11 | "source": [ 12 | "# Agent Chat with custom model loading\n", 13 | "\n", 14 | "In this notebook, we demonstrate how a custom model can be defined and loaded, and what protocol it needs to comply to.\n", 15 | "\n", 16 | "**NOTE: Depending on what model you use, you may need to play with the default prompts of the Agent's**\n", 17 | "\n", 18 | "## Requirements\n", 19 | "\n", 20 | "````{=mdx}\n", 21 | ":::info Requirements\n", 22 | "Some extra dependencies are needed for this notebook, which can be installed via pip:\n", 23 | "\n", 24 | "```bash\n", 25 | "pip install pyautogen torch transformers sentencepiece\n", 26 | "```\n", 27 | "\n", 28 | "For more information, please refer to the [installation guide](/docs/installation/).\n", 29 | ":::\n", 30 | "````" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": null, 36 | "metadata": {}, 37 | "outputs": [], 38 | "source": [ 39 | "from types import SimpleNamespace\n", 40 | "\n", 41 | "from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig\n", 42 | "\n", 43 | "import autogen\n", 44 | "from autogen import AssistantAgent, UserProxyAgent" 45 | ] 46 | }, 47 | { 48 | "cell_type": "markdown", 49 | "metadata": {}, 50 | "source": [ 51 | "## Create and configure the custom model\n", 52 | "\n", 53 | "A custom model class can be created in many ways, but needs to adhere to the `ModelClient` protocol and response structure which is defined in client.py and shown below.\n", 54 | "\n", 55 | "The response protocol has some minimum requirements, but can be extended to include any additional information that is needed.\n", 56 | "Message retrieval therefore can be customized, but needs to return a list of strings or a list of `ModelClientResponseProtocol.Choice.Message` objects.\n", 57 | "\n", 58 | "\n", 59 | "```python\n", 60 | "class ModelClient(Protocol):\n", 61 | " \"\"\"\n", 62 | " A client class must implement the following methods:\n", 63 | " - create must return a response object that implements the ModelClientResponseProtocol\n", 64 | " - cost must return the cost of the response\n", 65 | " - get_usage must return a dict with the following keys:\n", 66 | " - prompt_tokens\n", 67 | " - completion_tokens\n", 68 | " - total_tokens\n", 69 | " - cost\n", 70 | " - model\n", 71 | "\n", 72 | " This class is used to create a client that can be used by OpenAIWrapper.\n", 73 | " The response returned from create must adhere to the ModelClientResponseProtocol but can be extended however needed.\n", 74 | " The message_retrieval method must be implemented to return a list of str or a list of messages from the response.\n", 75 | " \"\"\"\n", 76 | "\n", 77 | " RESPONSE_USAGE_KEYS = [\"prompt_tokens\", \"completion_tokens\", \"total_tokens\", \"cost\", \"model\"]\n", 78 | "\n", 79 | " class ModelClientResponseProtocol(Protocol):\n", 80 | " class Choice(Protocol):\n", 81 | " class Message(Protocol):\n", 82 | " content: Optional[str]\n", 83 | "\n", 84 | " message: Message\n", 85 | "\n", 86 | " choices: List[Choice]\n", 87 | " model: str\n", 88 | "\n", 89 | " def create(self, params) -> ModelClientResponseProtocol:\n", 90 | " ...\n", 91 | "\n", 92 | " def message_retrieval(\n", 93 | " self, response: ModelClientResponseProtocol\n", 94 | " ) -> Union[List[str], List[ModelClient.ModelClientResponseProtocol.Choice.Message]]:\n", 95 | " \"\"\"\n", 96 | " Retrieve and return a list of strings or a list of Choice.Message from the response.\n", 97 | "\n", 98 | " NOTE: if a list of Choice.Message is returned, it currently needs to contain the fields of OpenAI's ChatCompletion Message object,\n", 99 | " since that is expected for function or tool calling in the rest of the codebase at the moment, unless a custom agent is being used.\n", 100 | " \"\"\"\n", 101 | " ...\n", 102 | "\n", 103 | " def cost(self, response: ModelClientResponseProtocol) -> float:\n", 104 | " ...\n", 105 | "\n", 106 | " @staticmethod\n", 107 | " def get_usage(response: ModelClientResponseProtocol) -> Dict:\n", 108 | " \"\"\"Return usage summary of the response using RESPONSE_USAGE_KEYS.\"\"\"\n", 109 | " ...\n", 110 | "```\n" 111 | ] 112 | }, 113 | { 114 | "cell_type": "markdown", 115 | "metadata": {}, 116 | "source": [ 117 | "## Example of simple custom client\n", 118 | "\n", 119 | "Following the huggingface example for using [Mistral's Open-Orca](https://huggingface.co/Open-Orca/Mistral-7B-OpenOrca)\n", 120 | "\n", 121 | "For the response object, python's `SimpleNamespace` is used to create a simple object that can be used to store the response data, but any object that follows the `ClientResponseProtocol` can be used.\n" 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": null, 127 | "metadata": {}, 128 | "outputs": [], 129 | "source": [ 130 | "# custom client with custom model loader\n", 131 | "\n", 132 | "\n", 133 | "class CustomModelClient:\n", 134 | " def __init__(self, config, **kwargs):\n", 135 | " print(f\"CustomModelClient config: {config}\")\n", 136 | " self.device = config.get(\"device\", \"cpu\")\n", 137 | " self.model = AutoModelForCausalLM.from_pretrained(config[\"model\"]).to(self.device)\n", 138 | " self.model_name = config[\"model\"]\n", 139 | " self.tokenizer = AutoTokenizer.from_pretrained(config[\"model\"], use_fast=False)\n", 140 | " self.tokenizer.pad_token_id = self.tokenizer.eos_token_id\n", 141 | "\n", 142 | " # params are set by the user and consumed by the user since they are providing a custom model\n", 143 | " # so anything can be done here\n", 144 | " gen_config_params = config.get(\"params\", {})\n", 145 | " self.max_length = gen_config_params.get(\"max_length\", 256)\n", 146 | "\n", 147 | " print(f\"Loaded model {config['model']} to {self.device}\")\n", 148 | "\n", 149 | " def create(self, params):\n", 150 | " if params.get(\"stream\", False) and \"messages\" in params:\n", 151 | " raise NotImplementedError(\"Local models do not support streaming.\")\n", 152 | " else:\n", 153 | " num_of_responses = params.get(\"n\", 1)\n", 154 | "\n", 155 | " # can create my own data response class\n", 156 | " # here using SimpleNamespace for simplicity\n", 157 | " # as long as it adheres to the ClientResponseProtocol\n", 158 | "\n", 159 | " response = SimpleNamespace()\n", 160 | "\n", 161 | " inputs = self.tokenizer.apply_chat_template(\n", 162 | " params[\"messages\"], return_tensors=\"pt\", add_generation_prompt=True\n", 163 | " ).to(self.device)\n", 164 | " inputs_length = inputs.shape[-1]\n", 165 | "\n", 166 | " # add inputs_length to max_length\n", 167 | " max_length = self.max_length + inputs_length\n", 168 | " generation_config = GenerationConfig(\n", 169 | " max_length=max_length,\n", 170 | " eos_token_id=self.tokenizer.eos_token_id,\n", 171 | " pad_token_id=self.tokenizer.eos_token_id,\n", 172 | " )\n", 173 | "\n", 174 | " response.choices = []\n", 175 | " response.model = self.model_name\n", 176 | "\n", 177 | " for _ in range(num_of_responses):\n", 178 | " outputs = self.model.generate(inputs, generation_config=generation_config)\n", 179 | " # Decode only the newly generated text, excluding the prompt\n", 180 | " text = self.tokenizer.decode(outputs[0, inputs_length:])\n", 181 | " choice = SimpleNamespace()\n", 182 | " choice.message = SimpleNamespace()\n", 183 | " choice.message.content = text\n", 184 | " choice.message.function_call = None\n", 185 | " response.choices.append(choice)\n", 186 | "\n", 187 | " return response\n", 188 | "\n", 189 | " def message_retrieval(self, response):\n", 190 | " \"\"\"Retrieve the messages from the response.\"\"\"\n", 191 | " choices = response.choices\n", 192 | " return [choice.message.content for choice in choices]\n", 193 | "\n", 194 | " def cost(self, response) -> float:\n", 195 | " \"\"\"Calculate the cost of the response.\"\"\"\n", 196 | " response.cost = 0\n", 197 | " return 0\n", 198 | "\n", 199 | " @staticmethod\n", 200 | " def get_usage(response):\n", 201 | " # returns a dict of prompt_tokens, completion_tokens, total_tokens, cost, model\n", 202 | " # if usage needs to be tracked, else None\n", 203 | " return {}" 204 | ] 205 | }, 206 | { 207 | "attachments": {}, 208 | "cell_type": "markdown", 209 | "metadata": {}, 210 | "source": [ 211 | "## Set your API Endpoint\n", 212 | "\n", 213 | "The [`config_list_from_json`](https://microsoft.github.io/autogen/docs/reference/oai/openai_utils#config_list_from_json) function loads a list of configurations from an environment variable or a json file.\n", 214 | "\n", 215 | "It first looks for an environment variable of a specified name (\"OAI_CONFIG_LIST\" in this example), which needs to be a valid json string. If that variable is not found, it looks for a json file with the same name. It filters the configs by models (you can filter by other keys as well).\n", 216 | "\n", 217 | "The json looks like the following:\n", 218 | "```json\n", 219 | "[\n", 220 | " {\n", 221 | " \"model\": \"gpt-4\",\n", 222 | " \"api_key\": \"\"\n", 223 | " },\n", 224 | " {\n", 225 | " \"model\": \"gpt-4\",\n", 226 | " \"api_key\": \"\",\n", 227 | " \"base_url\": \"\",\n", 228 | " \"api_type\": \"azure\",\n", 229 | " \"api_version\": \"2024-02-15-preview\"\n", 230 | " },\n", 231 | " {\n", 232 | " \"model\": \"gpt-4-32k\",\n", 233 | " \"api_key\": \"\",\n", 234 | " \"base_url\": \"\",\n", 235 | " \"api_type\": \"azure\",\n", 236 | " \"api_version\": \"2024-02-15-preview\"\n", 237 | " }\n", 238 | "]\n", 239 | "```\n", 240 | "\n", 241 | "You can set the value of config_list in any way you prefer. Please refer to this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/oai_openai_utils.ipynb) for full code examples of the different methods." 242 | ] 243 | }, 244 | { 245 | "cell_type": "markdown", 246 | "metadata": {}, 247 | "source": [ 248 | "## Set the config for the custom model\n", 249 | "\n", 250 | "You can add any paramteres that are needed for the custom model loading in the same configuration list.\n", 251 | "\n", 252 | "It is important to add the `model_client_cls` field and set it to a string that corresponds to the class name: `\"CustomModelClient\"`.\n", 253 | "\n", 254 | "```json\n", 255 | "{\n", 256 | " \"model\": \"Open-Orca/Mistral-7B-OpenOrca\",\n", 257 | " \"model_client_cls\": \"CustomModelClient\",\n", 258 | " \"device\": \"cuda\",\n", 259 | " \"n\": 1,\n", 260 | " \"params\": {\n", 261 | " \"max_length\": 1000,\n", 262 | " }\n", 263 | "},\n", 264 | "```" 265 | ] 266 | }, 267 | { 268 | "cell_type": "code", 269 | "execution_count": null, 270 | "metadata": {}, 271 | "outputs": [], 272 | "source": [ 273 | "config_list_custom = autogen.config_list_from_json(\n", 274 | " \"OAI_CONFIG_LIST\",\n", 275 | " filter_dict={\"model_client_cls\": [\"CustomModelClient\"]},\n", 276 | ")" 277 | ] 278 | }, 279 | { 280 | "attachments": {}, 281 | "cell_type": "markdown", 282 | "metadata": {}, 283 | "source": [ 284 | "## Construct Agents\n", 285 | "\n", 286 | "Consturct a simple conversation between a User proxy and an Assistent agent" 287 | ] 288 | }, 289 | { 290 | "cell_type": "code", 291 | "execution_count": null, 292 | "metadata": {}, 293 | "outputs": [], 294 | "source": [ 295 | "assistant = AssistantAgent(\"assistant\", llm_config={\"config_list\": config_list_custom})\n", 296 | "user_proxy = UserProxyAgent(\n", 297 | " \"user_proxy\",\n", 298 | " code_execution_config={\n", 299 | " \"work_dir\": \"coding\",\n", 300 | " \"use_docker\": False, # Please set use_docker=True if docker is available to run the generated code. Using docker is safer than running the generated code directly.\n", 301 | " },\n", 302 | ")" 303 | ] 304 | }, 305 | { 306 | "cell_type": "markdown", 307 | "metadata": {}, 308 | "source": [ 309 | "## Register the custom client class to the assistant agent" 310 | ] 311 | }, 312 | { 313 | "cell_type": "code", 314 | "execution_count": null, 315 | "metadata": {}, 316 | "outputs": [], 317 | "source": [ 318 | "assistant.register_model_client(model_client_cls=CustomModelClient)" 319 | ] 320 | }, 321 | { 322 | "cell_type": "code", 323 | "execution_count": null, 324 | "metadata": {}, 325 | "outputs": [], 326 | "source": [ 327 | "user_proxy.initiate_chat(assistant, message=\"Write python code to print Hello World!\")" 328 | ] 329 | }, 330 | { 331 | "cell_type": "markdown", 332 | "metadata": {}, 333 | "source": [ 334 | "## Register a custom client class with a pre-loaded model\n", 335 | "\n", 336 | "If you want to have more control over when the model gets loaded, you can load the model yourself and pass it as an argument to the CustomClient during registration" 337 | ] 338 | }, 339 | { 340 | "cell_type": "code", 341 | "execution_count": null, 342 | "metadata": {}, 343 | "outputs": [], 344 | "source": [ 345 | "# custom client with custom model loader\n", 346 | "\n", 347 | "\n", 348 | "class CustomModelClientWithArguments(CustomModelClient):\n", 349 | " def __init__(self, config, loaded_model, tokenizer, **kwargs):\n", 350 | " print(f\"CustomModelClientWithArguments config: {config}\")\n", 351 | "\n", 352 | " self.model_name = config[\"model\"]\n", 353 | " self.model = loaded_model\n", 354 | " self.tokenizer = tokenizer\n", 355 | "\n", 356 | " self.device = config.get(\"device\", \"cpu\")\n", 357 | "\n", 358 | " gen_config_params = config.get(\"params\", {})\n", 359 | " self.max_length = gen_config_params.get(\"max_length\", 256)\n", 360 | " print(f\"Loaded model {config['model']} to {self.device}\")" 361 | ] 362 | }, 363 | { 364 | "cell_type": "code", 365 | "execution_count": null, 366 | "metadata": {}, 367 | "outputs": [], 368 | "source": [ 369 | "# load model here\n", 370 | "\n", 371 | "\n", 372 | "config = config_list_custom[0]\n", 373 | "device = config.get(\"device\", \"cpu\")\n", 374 | "loaded_model = AutoModelForCausalLM.from_pretrained(config[\"model\"]).to(device)\n", 375 | "tokenizer = AutoTokenizer.from_pretrained(config[\"model\"], use_fast=False)\n", 376 | "tokenizer.pad_token_id = tokenizer.eos_token_id" 377 | ] 378 | }, 379 | { 380 | "cell_type": "markdown", 381 | "metadata": {}, 382 | "source": [ 383 | "## Add the config of the new custom model\n", 384 | "\n", 385 | "```json\n", 386 | "{\n", 387 | " \"model\": \"Open-Orca/Mistral-7B-OpenOrca\",\n", 388 | " \"model_client_cls\": \"CustomModelClientWithArguments\",\n", 389 | " \"device\": \"cuda\",\n", 390 | " \"n\": 1,\n", 391 | " \"params\": {\n", 392 | " \"max_length\": 1000,\n", 393 | " }\n", 394 | "},\n", 395 | "```" 396 | ] 397 | }, 398 | { 399 | "cell_type": "code", 400 | "execution_count": null, 401 | "metadata": {}, 402 | "outputs": [], 403 | "source": [ 404 | "config_list_custom = autogen.config_list_from_json(\n", 405 | " \"OAI_CONFIG_LIST\",\n", 406 | " filter_dict={\"model_client_cls\": [\"CustomModelClientWithArguments\"]},\n", 407 | ")" 408 | ] 409 | }, 410 | { 411 | "cell_type": "code", 412 | "execution_count": null, 413 | "metadata": {}, 414 | "outputs": [], 415 | "source": [ 416 | "assistant = AssistantAgent(\"assistant\", llm_config={\"config_list\": config_list_custom})" 417 | ] 418 | }, 419 | { 420 | "cell_type": "code", 421 | "execution_count": null, 422 | "metadata": {}, 423 | "outputs": [], 424 | "source": [ 425 | "assistant.register_model_client(\n", 426 | " model_client_cls=CustomModelClientWithArguments,\n", 427 | " loaded_model=loaded_model,\n", 428 | " tokenizer=tokenizer,\n", 429 | ")" 430 | ] 431 | }, 432 | { 433 | "cell_type": "code", 434 | "execution_count": null, 435 | "metadata": {}, 436 | "outputs": [], 437 | "source": [ 438 | "user_proxy.initiate_chat(assistant, message=\"Write python code to print Hello World!\")" 439 | ] 440 | } 441 | ], 442 | "metadata": { 443 | "front_matter": { 444 | "description": "Define and laod a custom model", 445 | "tags": [ 446 | "custom model" 447 | ] 448 | }, 449 | "kernelspec": { 450 | "display_name": "Python 3", 451 | "language": "python", 452 | "name": "python3" 453 | }, 454 | "language_info": { 455 | "codemirror_mode": { 456 | "name": "ipython", 457 | "version": 3 458 | }, 459 | "file_extension": ".py", 460 | "mimetype": "text/x-python", 461 | "name": "python", 462 | "nbconvert_exporter": "python", 463 | "pygments_lexer": "ipython3", 464 | "version": "3.9.5" 465 | }, 466 | "vscode": { 467 | "interpreter": { 468 | "hash": "949777d72b0d2535278d3dc13498b2535136f6dfe0678499012e853ee9abcab1" 469 | } 470 | }, 471 | "widgets": { 472 | "application/vnd.jupyter.widget-state+json": { 473 | "state": { 474 | "2d910cfd2d2a4fc49fc30fbbdc5576a7": { 475 | "model_module": "@jupyter-widgets/base", 476 | "model_module_version": "2.0.0", 477 | "model_name": "LayoutModel", 478 | "state": { 479 | "_model_module": "@jupyter-widgets/base", 480 | "_model_module_version": "2.0.0", 481 | "_model_name": "LayoutModel", 482 | "_view_count": null, 483 | "_view_module": "@jupyter-widgets/base", 484 | "_view_module_version": "2.0.0", 485 | "_view_name": "LayoutView", 486 | "align_content": null, 487 | "align_items": null, 488 | "align_self": null, 489 | "border_bottom": null, 490 | "border_left": null, 491 | "border_right": null, 492 | "border_top": null, 493 | "bottom": null, 494 | "display": null, 495 | "flex": null, 496 | "flex_flow": null, 497 | "grid_area": null, 498 | "grid_auto_columns": null, 499 | "grid_auto_flow": null, 500 | "grid_auto_rows": null, 501 | "grid_column": null, 502 | "grid_gap": null, 503 | "grid_row": null, 504 | "grid_template_areas": null, 505 | "grid_template_columns": null, 506 | "grid_template_rows": null, 507 | "height": null, 508 | "justify_content": null, 509 | "justify_items": null, 510 | "left": null, 511 | "margin": null, 512 | "max_height": null, 513 | "max_width": null, 514 | "min_height": null, 515 | "min_width": null, 516 | "object_fit": null, 517 | "object_position": null, 518 | "order": null, 519 | "overflow": null, 520 | "padding": null, 521 | "right": null, 522 | "top": null, 523 | "visibility": null, 524 | "width": null 525 | } 526 | }, 527 | "454146d0f7224f038689031002906e6f": { 528 | "model_module": "@jupyter-widgets/controls", 529 | "model_module_version": "2.0.0", 530 | "model_name": "HBoxModel", 531 | "state": { 532 | "_dom_classes": [], 533 | "_model_module": "@jupyter-widgets/controls", 534 | "_model_module_version": "2.0.0", 535 | "_model_name": "HBoxModel", 536 | "_view_count": null, 537 | "_view_module": "@jupyter-widgets/controls", 538 | "_view_module_version": "2.0.0", 539 | "_view_name": "HBoxView", 540 | "box_style": "", 541 | "children": [ 542 | "IPY_MODEL_e4ae2b6f5a974fd4bafb6abb9d12ff26", 543 | "IPY_MODEL_577e1e3cc4db4942b0883577b3b52755", 544 | "IPY_MODEL_b40bdfb1ac1d4cffb7cefcb870c64d45" 545 | ], 546 | "layout": "IPY_MODEL_dc83c7bff2f241309537a8119dfc7555", 547 | "tabbable": null, 548 | "tooltip": null 549 | } 550 | }, 551 | "577e1e3cc4db4942b0883577b3b52755": { 552 | "model_module": "@jupyter-widgets/controls", 553 | "model_module_version": "2.0.0", 554 | "model_name": "FloatProgressModel", 555 | "state": { 556 | "_dom_classes": [], 557 | "_model_module": "@jupyter-widgets/controls", 558 | "_model_module_version": "2.0.0", 559 | "_model_name": "FloatProgressModel", 560 | "_view_count": null, 561 | "_view_module": "@jupyter-widgets/controls", 562 | "_view_module_version": "2.0.0", 563 | "_view_name": "ProgressView", 564 | "bar_style": "success", 565 | "description": "", 566 | "description_allow_html": false, 567 | "layout": "IPY_MODEL_2d910cfd2d2a4fc49fc30fbbdc5576a7", 568 | "max": 1, 569 | "min": 0, 570 | "orientation": "horizontal", 571 | "style": "IPY_MODEL_74a6ba0c3cbc4051be0a83e152fe1e62", 572 | "tabbable": null, 573 | "tooltip": null, 574 | "value": 1 575 | } 576 | }, 577 | "6086462a12d54bafa59d3c4566f06cb2": { 578 | "model_module": "@jupyter-widgets/base", 579 | "model_module_version": "2.0.0", 580 | "model_name": "LayoutModel", 581 | "state": { 582 | "_model_module": "@jupyter-widgets/base", 583 | "_model_module_version": "2.0.0", 584 | "_model_name": "LayoutModel", 585 | "_view_count": null, 586 | "_view_module": "@jupyter-widgets/base", 587 | "_view_module_version": "2.0.0", 588 | "_view_name": "LayoutView", 589 | "align_content": null, 590 | "align_items": null, 591 | "align_self": null, 592 | "border_bottom": null, 593 | "border_left": null, 594 | "border_right": null, 595 | "border_top": null, 596 | "bottom": null, 597 | "display": null, 598 | "flex": null, 599 | "flex_flow": null, 600 | "grid_area": null, 601 | "grid_auto_columns": null, 602 | "grid_auto_flow": null, 603 | "grid_auto_rows": null, 604 | "grid_column": null, 605 | "grid_gap": null, 606 | "grid_row": null, 607 | "grid_template_areas": null, 608 | "grid_template_columns": null, 609 | "grid_template_rows": null, 610 | "height": null, 611 | "justify_content": null, 612 | "justify_items": null, 613 | "left": null, 614 | "margin": null, 615 | "max_height": null, 616 | "max_width": null, 617 | "min_height": null, 618 | "min_width": null, 619 | "object_fit": null, 620 | "object_position": null, 621 | "order": null, 622 | "overflow": null, 623 | "padding": null, 624 | "right": null, 625 | "top": null, 626 | "visibility": null, 627 | "width": null 628 | } 629 | }, 630 | "74a6ba0c3cbc4051be0a83e152fe1e62": { 631 | "model_module": "@jupyter-widgets/controls", 632 | "model_module_version": "2.0.0", 633 | "model_name": "ProgressStyleModel", 634 | "state": { 635 | "_model_module": "@jupyter-widgets/controls", 636 | "_model_module_version": "2.0.0", 637 | "_model_name": "ProgressStyleModel", 638 | "_view_count": null, 639 | "_view_module": "@jupyter-widgets/base", 640 | "_view_module_version": "2.0.0", 641 | "_view_name": "StyleView", 642 | "bar_color": null, 643 | "description_width": "" 644 | } 645 | }, 646 | "7d3f3d9e15894d05a4d188ff4f466554": { 647 | "model_module": "@jupyter-widgets/controls", 648 | "model_module_version": "2.0.0", 649 | "model_name": "HTMLStyleModel", 650 | "state": { 651 | "_model_module": "@jupyter-widgets/controls", 652 | "_model_module_version": "2.0.0", 653 | "_model_name": "HTMLStyleModel", 654 | "_view_count": null, 655 | "_view_module": "@jupyter-widgets/base", 656 | "_view_module_version": "2.0.0", 657 | "_view_name": "StyleView", 658 | "background": null, 659 | "description_width": "", 660 | "font_size": null, 661 | "text_color": null 662 | } 663 | }, 664 | "b40bdfb1ac1d4cffb7cefcb870c64d45": { 665 | "model_module": "@jupyter-widgets/controls", 666 | "model_module_version": "2.0.0", 667 | "model_name": "HTMLModel", 668 | "state": { 669 | "_dom_classes": [], 670 | "_model_module": "@jupyter-widgets/controls", 671 | "_model_module_version": "2.0.0", 672 | "_model_name": "HTMLModel", 673 | "_view_count": null, 674 | "_view_module": "@jupyter-widgets/controls", 675 | "_view_module_version": "2.0.0", 676 | "_view_name": "HTMLView", 677 | "description": "", 678 | "description_allow_html": false, 679 | "layout": "IPY_MODEL_f1355871cc6f4dd4b50d9df5af20e5c8", 680 | "placeholder": "​", 681 | "style": "IPY_MODEL_ca245376fd9f4354af6b2befe4af4466", 682 | "tabbable": null, 683 | "tooltip": null, 684 | "value": " 1/1 [00:00<00:00, 44.69it/s]" 685 | } 686 | }, 687 | "ca245376fd9f4354af6b2befe4af4466": { 688 | "model_module": "@jupyter-widgets/controls", 689 | "model_module_version": "2.0.0", 690 | "model_name": "HTMLStyleModel", 691 | "state": { 692 | "_model_module": "@jupyter-widgets/controls", 693 | "_model_module_version": "2.0.0", 694 | "_model_name": "HTMLStyleModel", 695 | "_view_count": null, 696 | "_view_module": "@jupyter-widgets/base", 697 | "_view_module_version": "2.0.0", 698 | "_view_name": "StyleView", 699 | "background": null, 700 | "description_width": "", 701 | "font_size": null, 702 | "text_color": null 703 | } 704 | }, 705 | "dc83c7bff2f241309537a8119dfc7555": { 706 | "model_module": "@jupyter-widgets/base", 707 | "model_module_version": "2.0.0", 708 | "model_name": "LayoutModel", 709 | "state": { 710 | "_model_module": "@jupyter-widgets/base", 711 | "_model_module_version": "2.0.0", 712 | "_model_name": "LayoutModel", 713 | "_view_count": null, 714 | "_view_module": "@jupyter-widgets/base", 715 | "_view_module_version": "2.0.0", 716 | "_view_name": "LayoutView", 717 | "align_content": null, 718 | "align_items": null, 719 | "align_self": null, 720 | "border_bottom": null, 721 | "border_left": null, 722 | "border_right": null, 723 | "border_top": null, 724 | "bottom": null, 725 | "display": null, 726 | "flex": null, 727 | "flex_flow": null, 728 | "grid_area": null, 729 | "grid_auto_columns": null, 730 | "grid_auto_flow": null, 731 | "grid_auto_rows": null, 732 | "grid_column": null, 733 | "grid_gap": null, 734 | "grid_row": null, 735 | "grid_template_areas": null, 736 | "grid_template_columns": null, 737 | "grid_template_rows": null, 738 | "height": null, 739 | "justify_content": null, 740 | "justify_items": null, 741 | "left": null, 742 | "margin": null, 743 | "max_height": null, 744 | "max_width": null, 745 | "min_height": null, 746 | "min_width": null, 747 | "object_fit": null, 748 | "object_position": null, 749 | "order": null, 750 | "overflow": null, 751 | "padding": null, 752 | "right": null, 753 | "top": null, 754 | "visibility": null, 755 | "width": null 756 | } 757 | }, 758 | "e4ae2b6f5a974fd4bafb6abb9d12ff26": { 759 | "model_module": "@jupyter-widgets/controls", 760 | "model_module_version": "2.0.0", 761 | "model_name": "HTMLModel", 762 | "state": { 763 | "_dom_classes": [], 764 | "_model_module": "@jupyter-widgets/controls", 765 | "_model_module_version": "2.0.0", 766 | "_model_name": "HTMLModel", 767 | "_view_count": null, 768 | "_view_module": "@jupyter-widgets/controls", 769 | "_view_module_version": "2.0.0", 770 | "_view_name": "HTMLView", 771 | "description": "", 772 | "description_allow_html": false, 773 | "layout": "IPY_MODEL_6086462a12d54bafa59d3c4566f06cb2", 774 | "placeholder": "​", 775 | "style": "IPY_MODEL_7d3f3d9e15894d05a4d188ff4f466554", 776 | "tabbable": null, 777 | "tooltip": null, 778 | "value": "100%" 779 | } 780 | }, 781 | "f1355871cc6f4dd4b50d9df5af20e5c8": { 782 | "model_module": "@jupyter-widgets/base", 783 | "model_module_version": "2.0.0", 784 | "model_name": "LayoutModel", 785 | "state": { 786 | "_model_module": "@jupyter-widgets/base", 787 | "_model_module_version": "2.0.0", 788 | "_model_name": "LayoutModel", 789 | "_view_count": null, 790 | "_view_module": "@jupyter-widgets/base", 791 | "_view_module_version": "2.0.0", 792 | "_view_name": "LayoutView", 793 | "align_content": null, 794 | "align_items": null, 795 | "align_self": null, 796 | "border_bottom": null, 797 | "border_left": null, 798 | "border_right": null, 799 | "border_top": null, 800 | "bottom": null, 801 | "display": null, 802 | "flex": null, 803 | "flex_flow": null, 804 | "grid_area": null, 805 | "grid_auto_columns": null, 806 | "grid_auto_flow": null, 807 | "grid_auto_rows": null, 808 | "grid_column": null, 809 | "grid_gap": null, 810 | "grid_row": null, 811 | "grid_template_areas": null, 812 | "grid_template_columns": null, 813 | "grid_template_rows": null, 814 | "height": null, 815 | "justify_content": null, 816 | "justify_items": null, 817 | "left": null, 818 | "margin": null, 819 | "max_height": null, 820 | "max_width": null, 821 | "min_height": null, 822 | "min_width": null, 823 | "object_fit": null, 824 | "object_position": null, 825 | "order": null, 826 | "overflow": null, 827 | "padding": null, 828 | "right": null, 829 | "top": null, 830 | "visibility": null, 831 | "width": null 832 | } 833 | } 834 | }, 835 | "version_major": 2, 836 | "version_minor": 0 837 | } 838 | } 839 | }, 840 | "nbformat": 4, 841 | "nbformat_minor": 2 842 | } 843 | --------------------------------------------------------------------------------