Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: implement a GroupChatPipeline that agents can freely talk rather than speak one by one sequencely #252

Open
Morriaty-The-Murderer opened this issue May 24, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Morriaty-The-Murderer
Copy link

Is your feature request related to a problem? Please describe.
I'm trying to implement a GroupChatPipeline that agents can freely talk rather than speak one by one sequencely

SisterAgent: @MomAgent mommmmm! Tom hit me!!!!
MomAgent: oh my baby, let me check your injuries
MomAgent: em fine. That's not a big problem
SisterAgent: ouch! mom I really feel hurt
MomAgent: TOM YOU BASTARD! COME HERE RIGHT NOW!
BrotherAgent: what happended?

Describe the solution you'd like

# -*- coding:utf-8 -*-
# built-in packages
from typing import Callable, List

# third-party packages
from agentscope.agents import AgentBase


# self-defined packages


class GroupContext(object):
    pass


class BaseAgentAttendStrategy(object):
    # should an agent attend the group chat of current topic?
    pass


class KeywordsAgentAttendStrategy(BaseAgentAttendStrategy):
    # attend current topic if match some keywords
    pass


class BeenMentionedAgentAttendStrategy(BaseAgentAttendStrategy):
    # attend current topic if been mentioned
    pass


class AgentWithAttendStrategy(object):
    agent: AgentBase
    attend_strategies: List[BaseAgentAttendStrategy]


class GroupChatPipeline(object):
    def __init__(self):
        self.context = GroupContext()
        self.members: List[AgentWithAttendStrategy] = []

    def trigger_next_speaker(self, msg) -> AgentBase:
        pass

    def __call__(self,
                 start_agent: AgentBase,
                 start_words: str,
                 max_rounds: int,
                 ending_func: Callable[[GroupContext], bool]
                 ):
        next_speaker = start_agent
        msg = start_words
        n_round = 0
        while n_round < max_rounds and not ending_func(self.context):
            n_round += 1
            msg = next_speaker(msg)
            next_speaker = self.trigger_next_speaker(msg)

Additional context
I am wondering:

  1. Is there any existing workaround functions or tools to achieve the GroupChatPipeline?
  2. if Q1 answer is not. Do the team have a plan to make something alike?
@Morriaty-The-Murderer Morriaty-The-Murderer added the enhancement New feature or request label May 24, 2024
@Morriaty-The-Murderer Morriaty-The-Murderer changed the title [Feature]: [Feature]: implement a GroupChatPipeline that agents can freely talk rather than speak one by one sequencely May 24, 2024
@DavdGao
Copy link
Collaborator

DavdGao commented May 24, 2024

@Morriaty-The-Murderer I'm not sure if the example conversation with mentions meets your requirements?

@Morriaty-The-Murderer
Copy link
Author

Morriaty-The-Murderer commented May 29, 2024

hi @DavdGao , the example conversation with mentions is not very similar to the new feature I want to request.

The key point is freely chat, there is no fixed order, a group of Agents will decide whether to join the conversation based on the context and their own personality and memory. They can refuse to respond even if they have been metioned.

In short logic:

init_msg = Msg(role="assistant", content="....")

if SomeForcedRules:
    speaker = select_agent_by_forced_rules(agents, SomeForcedRules)
else:
    speaker = None
    max_prob = 0
    for bot in agents:
        possibilities = bot.think(f"how possible should I respond the msg: {init_msg}")
        if possibilities > max_prob:
            max_prob = possibilities
            speaker = bot
            
response = speaker()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants