I am trying out autogen and currently I am a newbie with regards to coding. I am trying to get multiple agents to communicate together, user_proxy, coder and critic. However, only user_proxy and coder are communicating.
Here is my code:
import autogen
config_list = [
{
'model': 'gpt-4-0613',
'api_key': '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'
}
]
llm_config={
"request_timeout": 600,
"seed": 42,
"config_list": config_list,
"temperature": 0,
}
coder = autogen.AssistantAgent(
name="Coder",
llm_config=llm_config,
)
critic = autogen.AssistantAgent(
name="Critic",
system_message="""Critic. You are a helpful assistant highly skilled in evaluating the quality of a given visualization code by providing a score from 1 to 10
- bugs (bugs): Are there bugs, logic errors, syntax errors or typos? Are there any reasons why the code may fail to compile? How should it be fixed?
- Data transformation (transformation): Is the data transformed appropriately for the visualization type?
- Goal: compliance (compliance): How well the code meets the specified visualization goals?
- Visualization type (type): CONSIDERING BEST PRACTICES, is the visualization type appropriate for the data and intent?
- Data encoding (encoding): Is the data encoded appropriately for the visualization type?
- Aesthetics (aesthetics): Are the aesthetics of the visualization appropriate for the visualization type and the data?
YOUMUST PROVIDE A SCORE for each of the above dimensions.
{bugs: 0, transformation: 0, compliance: 0, type: 0, encoding: 0, aesthetics: 0}
Do not suggest code.
Finally, based on the critique above, suggest a concrete list of actions that the coder should take to improve the code.
""",
llm_config=llm_config,
)
user_proxy = autogen.UserProxyAgent(
name="user_proxy",
human_input_mode="TERMINATE",
max_consecutive_auto_reply=5,
is_termination_msg=lambda x: x.get("content", "").rstrip().endswith("TERMINATE"),
code_execution_config={"work_dir": "web"},
llm_config=llm_config,
system_message="""Reply TERMINATE if the task has been solved at full satisfaction.
Otherwise, reply CONTINUE, or the reason why the task is not solved yet."""
)
task = """
build a simple snake game. add a score counter to the top left. every 10 points a special food appars and increases the score by 5.
"""
user_proxy.initiate_chat(
coder,
critic,
message=task
)
I added critic to check certain criteria:
critic = autogen.AssistantAgent(
name="Critic",
system_message="""Critic. You are a helpful assistant highly skilled in evaluating the quality of a given visualization code by providing a score from 1 to 10
- bugs (bugs): Are there bugs, logic errors, syntax errors or typos? Are there any reasons why the code may fail to compile? How should it be fixed?
- Data transformation (transformation): Is the data transformed appropriately for the visualization type?
- Goal: compliance (compliance): How well the code meets the specified visualization goals?
- Visualization type (type): CONSIDERING BEST PRACTICES, is the visualization type appropriate for the data and intent?
- Data encoding (encoding): Is the data encoded appropriately for the visualization type?
- Aesthetics (aesthetics): Are the aesthetics of the visualization appropriate for the visualization type and the data?
YOUMUST PROVIDE A SCORE for each of the above dimensions.
{bugs: 0, transformation: 0, compliance: 0, type: 0, encoding: 0, aesthetics: 0}
Do not suggest code.
Finally, based on the critique above, suggest a concrete list of actions that the coder should take to improve the code.
""",
llm_config=llm_config,
)
To make it "work" I added the critic agent here:
user_proxy.initiate_chat(
coder,
critic,
message=task
)
You are missing the groupchat and groupchatmanager modules which are needed here. Refer https://github.com/microsoft/autogen/blob/main/notebook/agentchat_groupchat.ipynb.
In your case: