From 402c5bf8d1761d4cdac87eaf2faafce2a4943865 Mon Sep 17 00:00:00 2001 From: Chi Wang Date: Thu, 28 Sep 2023 13:14:36 -0700 Subject: [PATCH] Fix bug for windows and improve sample code (#38) * fix bug for windows * fix bug for windows * more clear example * link to example * add test * format * comment * fix assertion error * fix test error and links --------- Co-authored-by: Chi Wang (MSR) --- .gitignore | 5 ++ OAI_CONFIG_LIST_sample | 21 ++++++++ README.md | 19 +++++-- autogen/agentchat/assistant_agent.py | 2 +- autogen/code_utils.py | 20 +++++-- autogen/version.py | 2 +- notebook/agentchat_MathChat.ipynb | 4 +- notebook/agentchat_RetrieveChat.ipynb | 3 +- ...at_auto_feedback_from_code_execution.ipynb | 2 +- notebook/agentchat_chess.ipynb | 2 +- notebook/agentchat_function_call.ipynb | 2 +- notebook/agentchat_groupchat.ipynb | 2 +- notebook/agentchat_groupchat_vis.ipynb | 4 +- notebook/agentchat_teaching.ipynb | 7 ++- notebook/oai_chatgpt_gpt4.ipynb | 2 +- notebook/oai_completion.ipynb | 4 +- test/test_code.py | 52 +++++++++++++------ test/twoagent.py | 9 ++++ website/docs/Getting-Started.md | 15 ++++-- 19 files changed, 132 insertions(+), 45 deletions(-) create mode 100644 OAI_CONFIG_LIST_sample create mode 100644 test/twoagent.py diff --git a/.gitignore b/.gitignore index bb99e22a6975..98517f9d6908 100644 --- a/.gitignore +++ b/.gitignore @@ -159,3 +159,8 @@ output/ # local config files *.config.local +OAI_CONFIG_LIST +key_openai.txt +key_aoai.txt +base_aoai.txt +wolfram.txt diff --git a/OAI_CONFIG_LIST_sample b/OAI_CONFIG_LIST_sample new file mode 100644 index 000000000000..01608aeeef8e --- /dev/null +++ b/OAI_CONFIG_LIST_sample @@ -0,0 +1,21 @@ +// Please modify the content, remove this comment and rename this file to OAI_CONFIG_LIST to run the sample code. +[ + { + "model": "gpt-4", + "api_key": "" + }, + { + "model": "gpt-4", + "api_key": "", + "api_base": "", + "api_type": "azure", + "api_version": "2023-07-01-preview" + }, + { + "model": "gpt-3.5-turbo", + "api_key": "", + "api_base": "", + "api_type": "azure", + "api_version": "2023-07-01-preview" + } +] diff --git a/README.md b/README.md index e8853ffb2594..005f63c60644 100644 --- a/README.md +++ b/README.md @@ -60,15 +60,24 @@ For LLM inference configurations, check the [FAQ](https://microsoft.github.io/au ## Quickstart * Autogen enables the next-gen LLM applications with a generic multi-agent conversation framework. It offers customizable and conversable agents which integrate LLMs, tools and human. -By automating chat among multiple capable agents, one can easily make them collectively perform tasks autonomously or with human feedback, including tasks that require using tools via code. For example, +By automating chat among multiple capable agents, one can easily make them collectively perform tasks autonomously or with human feedback, including tasks that require using tools via code. For [example](https://github.com/microsoft/autogen/blob/main/test/twoagent.py), ```python -from autogen import AssistantAgent, UserProxyAgent -assistant = AssistantAgent("assistant") -user_proxy = UserProxyAgent("user_proxy") -user_proxy.initiate_chat(assistant, message="Plot a chart of META and TESLA stock price change YTD.") +from autogen import AssistantAgent, UserProxyAgent, config_list_from_json +# Load LLM inference endpoints from an env variable or a file +# See https://microsoft.github.io/autogen/docs/FAQ#set-your-api-endpoints +# and OAI_CONFIG_LIST_sample.json +config_list = config_list_from_json(env_or_file="OAI_CONFIG_LIST") +assistant = AssistantAgent("assistant", llm_config={"config_list": config_list}) +user_proxy = UserProxyAgent("user_proxy", code_execution_config={"work_dir": "coding"}) +user_proxy.initiate_chat(assistant, message="Plot a chart of NVDA and TESLA stock price change YTD.") # This initiates an automated chat between the two agents to solve the task ``` +This example can be run with +```python +python test/twoagent.py +``` +After the repo is cloned. The figure below shows an example conversation flow with AutoGen. ![Agent Chat Example](https://github.com/microsoft/autogen/blob/main/website/static/img/chat_example.png) diff --git a/autogen/agentchat/assistant_agent.py b/autogen/agentchat/assistant_agent.py index c8528884cd09..cac322774bae 100644 --- a/autogen/agentchat/assistant_agent.py +++ b/autogen/agentchat/assistant_agent.py @@ -16,7 +16,7 @@ class AssistantAgent(ConversableAgent): DEFAULT_SYSTEM_MESSAGE = """You are a helpful AI assistant. Solve tasks using your coding and language skills. In the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute. - 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself. + 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself. 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly. Solve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill. When using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code. So do not suggest incomplete code which requires users to modify. Don't use a code block if it's not intended to be executed by the user. diff --git a/autogen/code_utils.py b/autogen/code_utils.py index 1a6b970c6427..e5e0a7e3a6e3 100644 --- a/autogen/code_utils.py +++ b/autogen/code_utils.py @@ -23,6 +23,8 @@ UNKNOWN = "unknown" TIMEOUT_MSG = "Timeout" DEFAULT_TIMEOUT = 600 +WIN32 = sys.platform == "win32" +PATH_SEPARATOR = WIN32 and "\\" or "/" def infer_lang(code): @@ -193,10 +195,12 @@ def timeout_handler(signum, frame): def _cmd(lang): - if lang.startswith("python") or lang in ["bash", "sh"]: + if lang.startswith("python") or lang in ["bash", "sh", "powershell"]: return lang - if lang == "shell": + if lang in ["shell"]: return "sh" + if lang in ["ps1"]: + return "powershell" raise NotImplementedError(f"{lang} not recognized in code execution") @@ -242,6 +246,8 @@ def execute_code( assert code is not None or filename is not None, "Either code or filename must be provided." timeout = timeout or DEFAULT_TIMEOUT original_filename = filename + if WIN32 and lang in ["sh", "shell"]: + lang = "ps1" if filename is None: code_hash = md5(code.encode()).hexdigest() # create a file with a automatically generated name @@ -258,13 +264,17 @@ def execute_code( in_docker_container = os.path.exists("/.dockerenv") if not use_docker or in_docker_container: # already running in a docker container - cmd = [sys.executable if lang.startswith("python") else _cmd(lang), filename] - if sys.platform == "win32": + cmd = [ + sys.executable if lang.startswith("python") else _cmd(lang), + f".\\{filename}" if WIN32 else filename, + ] + if WIN32: logging.warning("SIGALRM is not supported on Windows. No timeout will be enforced.") result = subprocess.run( cmd, cwd=work_dir, capture_output=True, + text=True, ) else: signal.signal(signal.SIGALRM, timeout_handler) @@ -290,7 +300,7 @@ def execute_code( abs_path = str(pathlib.Path(filepath).absolute()) logs = logs.replace(str(abs_path), "").replace(filename, "") else: - abs_path = str(pathlib.Path(work_dir).absolute()) + "/" + abs_path = str(pathlib.Path(work_dir).absolute()) + PATH_SEPARATOR logs = logs.replace(str(abs_path), "") else: logs = result.stdout diff --git a/autogen/version.py b/autogen/version.py index b3f4756216d0..ae7362549b3c 100644 --- a/autogen/version.py +++ b/autogen/version.py @@ -1 +1 @@ -__version__ = "0.1.2" +__version__ = "0.1.3" diff --git a/notebook/agentchat_MathChat.ipynb b/notebook/agentchat_MathChat.ipynb index bd7f75db5c7d..226355c07d75 100644 --- a/notebook/agentchat_MathChat.ipynb +++ b/notebook/agentchat_MathChat.ipynb @@ -5,7 +5,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "\"Open" + "\"Open" ] }, { @@ -43,7 +43,7 @@ "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" + "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" ] }, { diff --git a/notebook/agentchat_RetrieveChat.ipynb b/notebook/agentchat_RetrieveChat.ipynb index 492f207d5956..035dd01d8692 100644 --- a/notebook/agentchat_RetrieveChat.ipynb +++ b/notebook/agentchat_RetrieveChat.ipynb @@ -62,7 +62,7 @@ "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" + "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" ] }, { @@ -3684,6 +3684,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ diff --git a/notebook/agentchat_auto_feedback_from_code_execution.ipynb b/notebook/agentchat_auto_feedback_from_code_execution.ipynb index de81cf4f3f26..b26412f4ffb6 100644 --- a/notebook/agentchat_auto_feedback_from_code_execution.ipynb +++ b/notebook/agentchat_auto_feedback_from_code_execution.ipynb @@ -55,7 +55,7 @@ "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" + "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" ] }, { diff --git a/notebook/agentchat_chess.ipynb b/notebook/agentchat_chess.ipynb index d859f4701740..d104eeb0ee85 100644 --- a/notebook/agentchat_chess.ipynb +++ b/notebook/agentchat_chess.ipynb @@ -56,7 +56,7 @@ "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." + "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." ] }, { diff --git a/notebook/agentchat_function_call.ipynb b/notebook/agentchat_function_call.ipynb index 3c481fffd6dd..4d0c2e9330c7 100644 --- a/notebook/agentchat_function_call.ipynb +++ b/notebook/agentchat_function_call.ipynb @@ -47,7 +47,7 @@ "source": [ "## Set your API Endpoint\n", "\n", - "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", + "The [`config_list_from_models`](https://microsoft.github.io/autogen/docs/reference/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", "\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", diff --git a/notebook/agentchat_groupchat.ipynb b/notebook/agentchat_groupchat.ipynb index 6964408ebcc7..da769f3a2d87 100644 --- a/notebook/agentchat_groupchat.ipynb +++ b/notebook/agentchat_groupchat.ipynb @@ -45,7 +45,7 @@ "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." + "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." ] }, { diff --git a/notebook/agentchat_groupchat_vis.ipynb b/notebook/agentchat_groupchat_vis.ipynb index 4348d224de05..1c619078f5af 100644 --- a/notebook/agentchat_groupchat_vis.ipynb +++ b/notebook/agentchat_groupchat_vis.ipynb @@ -43,7 +43,7 @@ "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." + "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." ] }, { @@ -1029,7 +1029,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.17" + "version": "3.10.12" }, "orig_nbformat": 4 }, diff --git a/notebook/agentchat_teaching.ipynb b/notebook/agentchat_teaching.ipynb index 8c79cb969c66..f11a91ae19bf 100644 --- a/notebook/agentchat_teaching.ipynb +++ b/notebook/agentchat_teaching.ipynb @@ -81,7 +81,7 @@ "metadata": {}, "outputs": [], "source": [ - "from flaml import autogen\n", + "import autogen\n", "\n", "llm_config={\n", " \"request_timeout\": 600,\n", @@ -95,6 +95,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -104,6 +105,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -138,6 +140,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -697,6 +700,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -825,6 +829,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ diff --git a/notebook/oai_chatgpt_gpt4.ipynb b/notebook/oai_chatgpt_gpt4.ipynb index c3f09943ed6b..9f273db8b5cd 100644 --- a/notebook/oai_chatgpt_gpt4.ipynb +++ b/notebook/oai_chatgpt_gpt4.ipynb @@ -88,7 +88,7 @@ "source": [ "### Set your API Endpoint\n", "\n", - "The [`config_list_openai_aoai`](https://microsoft.github.io/FLAML/docs/reference/autogen/oai/openai_utils#config_list_openai_aoai) function tries to create a list of Azure OpenAI endpoints and OpenAI endpoints. It assumes the api keys and api bases are stored in the corresponding environment variables or local txt files:\n", + "The [`config_list_openai_aoai`](https://microsoft.github.io/autogen/docs/reference/oai/openai_utils#config_list_openai_aoai) function tries to create a list of Azure OpenAI endpoints and OpenAI endpoints. It assumes the api keys and api bases are stored in the corresponding environment variables or local txt files:\n", "\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", diff --git a/notebook/oai_completion.ipynb b/notebook/oai_completion.ipynb index 01cd77a49629..029157490da4 100644 --- a/notebook/oai_completion.ipynb +++ b/notebook/oai_completion.ipynb @@ -59,11 +59,11 @@ "source": [ "## Set your API Endpoint\n", "\n", - "* The [`config_list_openai_aoai`](https://microsoft.github.io/FLAML/docs/reference/autogen/oai/openai_utils#config_list_openai_aoai) function tries to create a list of configurations using Azure OpenAI endpoints and OpenAI endpoints. It assumes the api keys and api bases are stored in the corresponding environment variables or local txt files:\n", + "* The [`config_list_openai_aoai`](https://microsoft.github.io/autogen/docs/reference/oai/openai_utils#config_list_openai_aoai) function tries to create a list of configurations using Azure OpenAI endpoints and OpenAI endpoints. It assumes the api keys and api bases are stored in the corresponding environment variables or local txt files:\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", - "* 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. It first looks for environment variable `env_or_file` which needs to be a valid json string. If that variable is not found, it then looks for a json file with the same name. It filters the configs by filter_dict.\n", + "* 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. It first looks for environment variable `env_or_file` which needs to be a valid json string. If that variable is not found, it then looks for a json file with the same name. It filters the configs by filter_dict.\n", "\n", "It's OK to have only the OpenAI API key, or only the Azure OpenAI API key + base. 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" ] diff --git a/test/test_code.py b/test/test_code.py index ab2d5d5917e0..3c967f65c5b6 100644 --- a/test/test_code.py +++ b/test/test_code.py @@ -9,6 +9,8 @@ infer_lang, improve_code, improve_function, + PATH_SEPARATOR, + WIN32, ) KEY_LOC = "notebook" @@ -214,36 +216,56 @@ def scrape(url): @pytest.mark.skipif( - sys.platform in ["darwin", "win32"], - reason="do not run on MacOS or windows", + sys.platform in ["darwin"], + reason="do not run on MacOS", ) -def test_execute_code(): +def test_execute_code(use_docker=None): try: import docker except ImportError as exc: print(exc) docker = None - exit_code, msg, image = execute_code("print('hello world')", filename="tmp/codetest.py") + if use_docker is None: + use_docker = docker is not None + exit_code, msg, image = execute_code("print('hello world')", filename="tmp/codetest.py", use_docker=use_docker) assert exit_code == 0 and msg == "hello world\n", msg # read a file - print(execute_code("with open('tmp/codetest.py', 'r') as f: a=f.read()")) + print(execute_code("with open('tmp/codetest.py', 'r') as f: a=f.read()", use_docker=use_docker)) # create a file exit_code, msg, image = execute_code( - "with open('tmp/codetest.py', 'w') as f: f.write('b=1')", work_dir=f"{here}/my_tmp", filename="tmp2/codetest.py" + "with open('tmp/codetest.py', 'w') as f: f.write('b=1')", + work_dir=f"{here}/my_tmp", + filename="tmp2/codetest.py", + use_docker=use_docker, + ) + assert exit_code and ( + 'File "tmp2/codetest.py"'.replace("/", PATH_SEPARATOR) in msg + or 'File ".\\tmp2/codetest.py' in msg # py3.8 + win32 + ), msg + print( + execute_code( + "with open('tmp/codetest.py', 'w') as f: f.write('b=1')", work_dir=f"{here}/my_tmp", use_docker=use_docker + ) ) - assert exit_code and 'File "tmp2/codetest.py"' in msg, msg - print(execute_code("with open('tmp/codetest.py', 'w') as f: f.write('b=1')", work_dir=f"{here}/my_tmp")) # execute code in a file - print(execute_code(filename="tmp/codetest.py")) - print(execute_code("python tmp/codetest.py", lang="sh")) + print(execute_code(filename="tmp/codetest.py", use_docker=use_docker)) + print(execute_code("python tmp/codetest.py", lang="sh", use_docker=use_docker)) # execute code for assertion error - exit_code, msg, image = execute_code("assert 1==2") + exit_code, msg, image = execute_code("assert 1==2", use_docker=use_docker) assert exit_code, msg - assert 'File ""' in msg + assert 'File ""' in msg or 'File ".\\"' in msg # py3.8 + win32 # execute code which takes a long time - exit_code, error, image = execute_code("import time; time.sleep(2)", timeout=1) - assert exit_code and error == "Timeout" - assert isinstance(image, str) or docker is None or os.path.exists("/.dockerenv") + exit_code, error, image = execute_code("import time; time.sleep(2)", timeout=1, use_docker=use_docker) + assert exit_code and error == "Timeout" or WIN32 + assert isinstance(image, str) or docker is None or os.path.exists("/.dockerenv") or use_docker is False + + +@pytest.mark.skipif( + sys.platform in ["darwin"], + reason="do not run on MacOS", +) +def test_execute_code_nodocker(): + test_execute_code(use_docker=False) def test_execute_code_no_docker(): diff --git a/test/twoagent.py b/test/twoagent.py new file mode 100644 index 000000000000..cc5c435d4858 --- /dev/null +++ b/test/twoagent.py @@ -0,0 +1,9 @@ +from autogen import AssistantAgent, UserProxyAgent, config_list_from_json + +# Load LLM inference endpoints from an env variable or a file +# See https://microsoft.github.io/autogen/docs/FAQ#set-your-api-endpoints +# and OAI_CONFIG_LIST_sample.json +config_list = config_list_from_json(env_or_file="OAI_CONFIG_LIST") +assistant = AssistantAgent("assistant", llm_config={"config_list": config_list}) +user_proxy = UserProxyAgent("user_proxy", code_execution_config={"work_dir": "coding"}) +user_proxy.initiate_chat(assistant, message="Plot a chart of NVDA and TESLA stock price change YTD.") diff --git a/website/docs/Getting-Started.md b/website/docs/Getting-Started.md index d8ae61830c50..e39f3f572317 100644 --- a/website/docs/Getting-Started.md +++ b/website/docs/Getting-Started.md @@ -25,12 +25,17 @@ Install from pip: `pip install pyautogen`. Find more options in [Installation](/ #### Multi-Agent Conversation Framework Autogen enables the next-gen LLM applications with a generic multi-agent conversation framework. It offers customizable and conversable agents which integrate LLMs, tools and human. -By automating chat among multiple capable agents, one can easily make them collectively perform tasks autonomously or with human feedback, including tasks that require using tools via code. For example, +By automating chat among multiple capable agents, one can easily make them collectively perform tasks autonomously or with human feedback, including tasks that require using tools via code. For [example](https://github.com/microsoft/autogen/blob/main/test/twoagent.py), ```python -from autogen import AssistantAgent, UserProxyAgent -assistant = AssistantAgent("assistant") -user_proxy = UserProxyAgent("user_proxy") -user_proxy.initiate_chat(assistant, message="Plot a chart of META and TESLA stock price change YTD.") +from autogen import AssistantAgent, UserProxyAgent, config_list_from_json + +# Load LLM inference endpoints from an env variable or a file +# See https://microsoft.github.io/autogen/docs/FAQ#set-your-api-endpoints +# and OAI_CONFIG_LIST_sample.json +config_list = config_list_from_json(env_or_file="OAI_CONFIG_LIST") +assistant = AssistantAgent("assistant", llm_config={"config_list": config_list}) +user_proxy = UserProxyAgent("user_proxy", code_execution_config={"work_dir": "coding"}) +user_proxy.initiate_chat(assistant, message="Plot a chart of NVDA and TESLA stock price change YTD.") # This initiates an automated chat between the two agents to solve the task ```