microsoft / autogen

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

Delivering multiple system messages is not supported by the local model deployed by the fschat-wrapped OpenAI API, which only supports a single system message #595

Open aizaiyishunjian opened 10 months ago

aizaiyishunjian commented 10 months ago

GroupChatManager requests the 'messages' of the model, passing multiple system messages.

{
    "messages":[
    {"role": "system", "content": "You are in a role play game. The following roles are available:\n User_proxy: \n Agency_Manager: \n   You are the Project Manager. Be concise and avoid pleasantries. Refrain from any conversations that don"t serve the goal of the user, ie.thank you... \n Agency_Researcher: \n ..."}, 
    {"role": "user", "name": "User_proxy", "content": "\n        如何提高公司订单效益\n        "}, 
    {"role": "system", "content": "Read the above conversation. Then select the next role from ['User_proxy', 'Agency_Manager', 'Agency_Researcher', 'Agency_Strategist', 'Agency_Copywriter'] to play. Only return the role."}]
}

However, for encapsulated OpenAI APIs like fschat, the setting of system messages is overridden, hence only one is retained.:

    def set_system_message(self, system_message: str):
        """Set the system message."""
        self.system_message = system_message

        for message in messages:
            msg_role = message["role"]
            if msg_role == "system":
                conv.set_system_message(message["content"])
            elif msg_role == "user":
                conv.append_message(conv.roles[0], message["content"])
            elif msg_role == "assistant":
                conv.append_message(conv.roles[1], message["content"])
            else:
                raise ValueError(f"Unknown role: {msg_role}")
afourney commented 10 months ago

It looks to me like these APIs would also have a problem with the "name" attribute that is important for Group Chat scenarios. I'm not sure compatibility will be easy to achieve. @LittleLittleCloud

sonichi commented 10 months ago

For the multi-system-message issue, you can override the select_speaker() function. The "name" attribute issue mentioned by @afourney needs attention too.

venkat-arvo commented 5 months ago

multiple 'system' messages are also causing a problem with using litellm proxy on claude 3 models. is there a work around for this issue?

ekzhu commented 5 months ago

multiple 'system' messages are also causing a problem with using litellm proxy on claude 3 models. is there a work around for this issue?

here is a potential fix, do you want to try to implement it? https://github.com/microsoft/autogen/issues/1861

afourney commented 5 months ago

Increasingly I think we need middleware for messages. The format AutoGen uses should be able to diverge from that used by the LLMs, with messages transformed just prior to making the LLM call.

j-dominguez9 commented 5 months ago

I'm getting the following error using groupchats with Claude-3. I believe it might be related to this issue. Followed the example on the documentation for configuration.

anthropic.BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages.0.name: Extra inputs are not permitted'}}