Merge pull request #973 from Wxysnx/20250723InteractiveGroupChat

fix random_speaker issues
pull/983/head^2
Kye Gomez 3 days ago committed by GitHub
commit 5b833ad5c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -951,6 +951,30 @@ Remember: You are part of a team. Your response should reflect that you've read,
for agent_name in speaking_order: for agent_name in speaking_order:
self._get_agent_response(agent_name, img, imgs) self._get_agent_response(agent_name, img, imgs)
def _process_random_speaker(
self,
mentioned_agents: List[str],
img: Optional[str],
imgs: Optional[List[str]],
) -> None:
"""
Process responses using the random speaker function.
This function randomly selects a single agent from the mentioned agents
to respond to the user query.
"""
# Filter out invalid agents
valid_agents = [name for name in mentioned_agents if name in self.agent_map]
if not valid_agents:
raise AgentNotFoundError("No valid agents found in the conversation")
# Randomly select exactly one agent to respond
random_agent = random.choice(valid_agents)
logger.info(f"Random speaker selected: {random_agent}")
# Get response from the randomly selected agent
self._get_agent_response(random_agent, img, imgs)
def run( def run(
self, self,
task: str, task: str,
@ -987,6 +1011,11 @@ Remember: You are part of a team. Your response should reflect that you've read,
self._process_dynamic_speakers( self._process_dynamic_speakers(
mentioned_agents, img, imgs mentioned_agents, img, imgs
) )
elif self.speaker_function == random_speaker:
# Use the specialized function for random_speaker
self._process_random_speaker(
mentioned_agents, img, imgs
)
else: else:
self._process_static_speakers( self._process_static_speakers(
mentioned_agents, img, imgs mentioned_agents, img, imgs

Loading…
Cancel
Save