#!/usr/bin/env python # coding: utf-8 # # Group Chat # # 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. # Please find documentation about this feature [here](https://microsoft.github.io/autogen/docs/Use-Cases/agent_chat). # # This notebook is modified based on https://github.com/microsoft/FLAML/blob/4ea686af5c3e8ff24d9076a7a626c8b28ab5b1d7/notebook/autogen_multiagent_roleplay_chat.ipynb # # ````{=mdx} # :::info Requirements # Install `autogen-agentchat`: # ```bash # pip install autogen-agentchat~=0.2 # ``` # # For more information, please refer to the [installation guide](/docs/installation/). # ::: # ```` # ## Set your API Endpoint # # 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. # In[106]: import autogen config_list = autogen.config_list_from_json( "OAI_CONFIG_LIST", filter_dict={ "model": ["gpt-4", "gpt-4-0314", "gpt4", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-v0314"], }, ) # ````{=mdx} # :::tip # Learn more about configuring LLMs for agents [here](/docs/topics/llm_configuration). # ::: # ```` # # ## Construct Agents # In[107]: llm_config = {"config_list": config_list, "cache_seed": 42} user_proxy = autogen.UserProxyAgent( name="User_proxy", system_message="A human admin.", code_execution_config={ "last_n_messages": 2, "work_dir": "groupchat", "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. human_input_mode="TERMINATE", ) coder = autogen.AssistantAgent( name="Coder", llm_config=llm_config, ) pm = autogen.AssistantAgent( name="Product_manager", system_message="Creative in software product ideas.", llm_config=llm_config, ) groupchat = autogen.GroupChat(agents=[user_proxy, coder, pm], messages=[], max_round=12) manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config) # ## Start Chat # In[108]: user_proxy.initiate_chat( manager, message="Find a latest paper about gpt-4 on arxiv and find its potential applications in software." ) # type exit to terminate the chat