Overview
GroupChat manages multi-agent conversations with configurable agent selection methods.
Class Signature
from qwen_agent.agents import GroupChat
class GroupChat(Agent, MultiAgentHub):
def __init__(
self,
agents: Union[List[Agent], Dict],
agent_selection_method: Optional[str] = 'auto',
function_list: Optional[List[Union[str, Dict, BaseTool]]] = None,
llm: Optional[Union[Dict, BaseChatModel]] = None,
**kwargs
)
Parameters
agents
Union[List[Agent], Dict]
required
List of agents or configuration dictionary
Selection method: ‘auto’, ‘round_robin’, ‘random’, ‘manual’
Usage Example
from qwen_agent.agents import GroupChat, Assistant
agents = [
Assistant(name='researcher', description='Research expert', llm={'model': 'qwen-max'}),
Assistant(name='writer', description='Content writer', llm={'model': 'qwen-max'})
]
group = GroupChat(
agents=agents,
agent_selection_method='auto',
llm={'model': 'qwen-max'}
)
messages = [{'role': 'user', 'content': 'Write a research article'}]
for response in group.run(messages, max_round=5):
print(response[-1].content)
See Also