microsoft / autogen

A programming framework for agentic AI 🤖
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
32.96k stars 4.8k forks source link

[Feature Request]: Allowing user to specify the "role" field for select speaker messages #1861

Closed ekzhu closed 7 months ago

ekzhu commented 8 months ago

Is your feature request related to a problem? Please describe.

Based on discussion in this thread: https://github.com/microsoft/autogen/issues/991. Mistral (and maybe other open source LLMs) requires the system messages to be before messages with user and assistant roles. So GroupChat select speaker "auto" mode can fail when the messages' roles are not in expected order.

I know #1791 is adding a more general way to address this, but a simpler approach should help to fix this without asking user to write custom function.

Describe the solution you'd like

In GroupChat's constructor, add a field role_for_select_speaker_messages with default set to system. use this field in select speaker function in "auto" mode.

Additional context

The expected values for role_for_select_speaker_messages would be system and user.

The role in current line:

https://github.com/microsoft/autogen/blob/c83d8d89e5e2b217e0a3a2a6f06346b2bb1786be/autogen/agentchat/groupchat.py#L384

can be customized based on the field role_for_select_speaker_messages.

No response

ekzhu commented 8 months ago

@joshkyh @kevin666aa @qingyun-wu @sonichi

joshkyh commented 8 months ago

Hey @ekzhu, can you give us some examples under Additional Context of this ticket on what are the expected values for role_for_select_speaker_messages and how each value would affect the GroupChat instance behaviour?

ekzhu commented 8 months ago

Hey @ekzhu, can you give us some examples under Additional Context of this ticket on what are the expected values for role_for_select_speaker_messages and how each value would affect the GroupChat instance behaviour?

Updated the description.

ekzhu commented 8 months ago

@YangQiuEric @Liques @richdrummer33 @akashAD98 @spincrisis @dsalas-crogl have all reported this issue.

marklysze commented 7 months ago

I've also recently had an issue with the role:system problem. I believe it was when I tried to use Huggingface's API, only user and assistant were valid roles. Being able to replace system with user would help.

marklysze commented 7 months ago

I'll look into this and try and get it sorted out :)

marklysze commented 7 months ago

I've submitted a PR, #2167, to address the change to GroupChat to enable the setting of the role name for select speaker messages.

New constructor parameter as per @ekzhu's suggestion above - role_for_select_speaker_messages on the GroupChat's constructor, which is an optional string attribute that defaults to system.

Also includes:

ekzhu commented 7 months ago

This is done by #2199