Code generation, execution, debugging and human feedback.
AssistantAgent
and
UserProxyAgent
to solve a challenging math problem with human
feedback. 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 “ALWAYS”, the UserProxyAgent
will always
prompt the user for feedback. When user feedback is provided, the
UserProxyAgent
will directly pass the feedback to AssistantAgent
.
When no user feedback is provided, the UserProxyAgent
will execute the
code written by AssistantAgent
and return the execution results
(success or failure and corresponding outputs) to AssistantAgent
.
Python>=3.9
. To run this notebook example, please
install:
config_list_from_json
function loads a list of configurations from an environment variable or
a json file.
initiate_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 receiving a message from the assistant agent. If
you don’t provide any feedback (by pressing Enter directly), the user
proxy agent will try to execute the code suggested by the assistant
agent on behalf of you, or terminate if the assistant agent sends a
“TERMINATE” signal at the end of the message.
user_proxy.chat_messages
.