To create an autogen design agent application: Create AI percentage agents and oppose ideas

Vision procedures often need to analyze time and debate. What if we make two llm coming up with ideas that made them negotiate with those ideas? Sounds interesting? This lesson illustrates how to build a powerful AI solution uses two llm agents associate with a formal conversation. By finding this we will use the autogen to build an agent with Chatgpt as a llm in our agent.
1. Setting and installation
Enter Install Packages:
pip install -U autogen-agentchat
pip install autogen-ext[openai]
2. Important nutrients
Let us consider the main parts of the autogen components that make the IDEA program work. Understanding these things will help you customize and extend the program for specific needs.
1. Roundrobgroupchat
- Has a team of agents based in revitalization.
- Estimates exchanges and responds, and all messages have been stolen in context.
- Ensures systematic and just-adjustment.
2. TextmentMinationMinationMination
- Masses the discussion when a particular keyword (eg, “Finish”) is available.
- Useful in eliminating conversations where agents reach a consensus or complete the work.
3. Helper
- Represents a member of the llm-powered group and a particular role.
- Each agent is described by the program of a system that directs its behavior.
- Agents use discussion history to produce discerning answers.
These components work together to create a systematic and joint program in which agents are thinking, debate, and to achieve decisions well.
3. Creating a group of agent
Create two special agents with different roles:
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.base import TaskResult
from autogen_agentchat.conditions import ExternalTermination, TextMentionTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_agentchat.ui import Console
from autogen_core import CancellationToken
from autogen_ext.models.openai import OpenAIChatCompletionClient
from apikey import API_KEY
# Create an OpenAI model client.
model_client = OpenAIChatCompletionClient(
model="gpt-4o-mini",
api_key=API_KEY,
)
# Create the primary agent.
primary_agent = AssistantAgent(
"participant1",
model_client=model_client,
system_message="You are a participant in an ideation and feedback session. You will be provided with a problem statement and asked to generate ideas. Your ideas will be
reviwed by another participant and then you together will narrow down ideas by debating over them. Respond with 'FINALIZE' when you have a final idea.",
)
# Create the critic agent.
critic_agent = AssistantAgent(
"participant2",
model_client=model_client,
system_message="You are a participant in an ideation and feedback session. Your teammate will be provide some ideas that you need to review with your
teammate and narrow down ideas by debating over them. Respond with 'FINALIZE' when you have a final idea.",
)
# Define a termination condition that stops the task if the critic approves.
text_termination = TextMentionTermination("FINALIZE")
# Create a team with the primary and critic agents.
team = RoundRobinGroupChat([primary_agent, critic_agent], termination_condition=text_termination)
4. Running a group
Working by Asynchronous processing:
result = await team.run(task="Generate ideas for an applications of AI in healthcare.")
print(result)
5. Monitoring is partnership
You can also track the dispute in real time:
# When running inside a script, use a async main function and call it from `asyncio.run(...)`.
await team.reset() # Reset the team for a new task.
async for message in team.run_stream(task="Generate ideas for an applications of AI in healthcare."): # type: ignore
if isinstance(message, TaskResult):
print("Stop Reason:", message.stop_reason)
else:
print(message)
Autogen also offers us to visualize the partnership in the best ways that use consolidation Work:
await team.reset() # Reset the team for a new task.
await Console(team.run_stream(task="Generate ideas for an applications of AI in healthcare.")) # Stream the messages to the console.
Now the program is perfect. But there is a lot to play with it, but I'll leave that to you. Here are a few ideas to improve your system:
- Adding Special Domain Agents (Medical Experts, Technical Technology)
- Applying Custom conditions
- To make a simple UI using streamlit
- Adding multiplayers in a group
References:

Weneet Kumar is a student of a consultant in MarktechPost. He currently pursued his BS from the Indian Institute of Technology (Iit), Kanpur. He is a machine learning enthusiasm. She is passionate about the recent research and anger in the deepest learning, computer idea and related fields.
