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

[.Net][Bug]: GroupChat #2624

Open
xuzeyu91 opened this issue May 8, 2024 · 12 comments
Open

[.Net][Bug]: GroupChat #2624

xuzeyu91 opened this issue May 8, 2024 · 12 comments
Labels
bug Something isn't working

Comments

@xuzeyu91
Copy link

xuzeyu91 commented May 8, 2024

Describe the bug

I often encounter issues when using group chats
"Sequence contains no matching element"

Steps to reproduce

   var groupChat = new GroupChat(
       admin: admin,
       members: agentList.ToArray()
   );
   userProxyAgent.SendIntroduction("Our group chat is about to start", groupChat);

   groupChatManager = new GroupChatManager(groupChat);

   var conversationHistory = await userProxyAgent.InitiateChatAsync(
         receiver: groupChatManager,
         message: msg,
         maxRound: 30);

This is my code, I used 2 custom GPTAgents, a UserProxyAgent as my input, and an Admin's GPTAgent
This error often occurs when starting a group chat:
Sequence contains no matching element
It seems to have happened earlier, and I'm not sure what logic is contained inside

Model Used

No response

Expected Behavior

No response

Screenshots and logs

No response

Additional Information

No response

@xuzeyu91 xuzeyu91 added the bug Something isn't working label May 8, 2024
@xuzeyu91
Copy link
Author

xuzeyu91 commented May 8, 2024

I am using the gpt-3.5-turbo-16k model

@LittleLittleCloud
Copy link
Collaborator

Sequence contains no matching element usually indicates that when generating the next speaker, admin agent fails to generate a name from one of group agents.

Can you share the complete example somewhere and I'm happy to take a look.

@xuzeyu91
Copy link
Author

xuzeyu91 commented May 9, 2024

https://github.com/xuzeyu91/EasyAgent/blob/main/src/EasyAgent/Pages/Chat/Chat.razor.cs
This is my code, and this error often occurs. I am not sure if it is due to an error in my agent settings or some other reason, but it is not necessarily the case

@LittleLittleCloud
Copy link
Collaborator

https://github.com/xuzeyu91/EasyAgent/blob/main/src/EasyAgent/Pages/Chat/Chat.razor.cs This is my code, and this error often occurs. I am not sure if it is due to an error in my agent settings or some other reason, but it is not necessarily the case

Thanks, what’s the name of group chat agents, are their name in English or Chinese?

@xuzeyu91
Copy link
Author

The names are in Chinese, respectively 刘备 ,张飞 and 关羽

@LittleLittleCloud
Copy link
Collaborator

Maybe try gpt-4 in admin agent? For what I know gpt-3.5 doesn't process Chinese very well.

If you want to stick with gpt-3.5, another trick you can use is to fall back to user agent when admin agent fails to select an agent in the group chat using middleware.

Also, when creating group chat, you don't need to add admin to agentList
https://github.com/xuzeyu91/EasyAgent/blob/6f3dd6410f9027ea892602d4d6af41c598299dbf/src/EasyAgent/Pages/Chat/Chat.razor.cs#L139

@xuzeyu91
Copy link
Author

xuzeyu91 commented May 11, 2024

another trick you can use is to fall back to user agent when admin agent fails to select an agent in the group chat using middleware.

How should this be operated? Is there an example, such as the minimum configuration being a user agent

@LittleLittleCloud
Copy link
Collaborator

@xuzeyu91 Here's an example, the idea is to use middlewhere to check the reply of an agent, if it's not one of from 张飞, from 关羽 or from 刘备, then return from UserName.

IAgent userAgent;

userAgent
   .RegisterMiddleware(async (messages, options, agent, ct) =>{
      var reply = await agent.GenerateResponse(messages, options, ct);
      var content = reply.GetContent();
      if (content is string text && (text == "from 张飞") || ..... )
      {
         // the next speaker is among the group, return the reply
         return reply; 
      }

      // otherwise, always fall back to user as next speaker
      return new TextMessage(Role.Assistant, "from User", from: agent.Name);
   });

@xuzeyu91
Copy link
Author

Thank you. Also, I would like to inquire that I did not use RoundRobinGroupChat but instead used GroupChat
But I feel that they also take turns answering questions for each agent, rather than being truly random. Is this normal?

@LittleLittleCloud
Copy link
Collaborator

@xuzeyu91 GroupChat uses admin to dynamically select the next speaker from members. For every conversation round, GroupChat firstly invokes admin to select the next speaker, then invoke the next speaker to generate the next message.

@xuzeyu91
Copy link
Author

But I feel that there is a high probability that each agent will take turns speaking once,The probability of the same agent speaking continuously or a certain agent not speaking is very low

@LittleLittleCloud
Copy link
Collaborator

Would you mind sharing a chat conversation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants