AssistantAgent and
UserProxyAgent to perform tasks which require acquiring info from the
web: * discuss a paper based on its URL. * discuss about the stock
market.
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 a user to
execute the code written by AssistantAgent. By setting
human_input_mode properly, the UserProxyAgent can also prompt the
user for feedback to AssistantAgent. For example, when
human_input_mode is set to “TERMINATE”, the UserProxyAgent will
execute the code written by AssistantAgent directly and return the
execution results (success or failure and corresponding outputs) to
AssistantAgent, and prompt the user for feedback when the task is
finished. When user feedback is provided, the UserProxyAgent will
directly pass the feedback to AssistantAgent.
Requirements
AG2 requiresPython>=3.9. To run this notebook example, please install
autogen and docker:
Set your API Endpoint
Theconfig_list_from_json
function loads a list of configurations from an environment variable or
a json file.
Construct Agents
We construct the assistant agent and the user proxy agent. We specifyhuman_input_mode as “TERMINATE” in the user proxy agent, which will
ask for human feedback when it receives a “TERMINATE” signal from the
assistant agent.
Example Task: Paper Talk from URL
We invoke theinitiate_chat() method of the user proxy agent to start
the conversation. When you run the cell below, you will be prompted to
provide feedback after the assistant agent sends a “TERMINATE” signal at
the end of the message. If you don’t provide any feedback (by pressing
Enter directly), the conversation will finish. Before the “TERMINATE”
signal, the user proxy agent will try to execute the code suggested by
the assistant agent on behalf of the user.