From 0871b3cb0b32b41d645b826618526505d0bc0f0a Mon Sep 17 00:00:00 2001 From: Mark Sze <66362098+marklysze@users.noreply.github.com> Date: Tue, 3 Sep 2024 18:15:13 +1000 Subject: [PATCH] Anthropic client class, concatenate system messages rather than lose them. (#3392) Co-authored-by: HRUSHIKESH DOKALA <96101829+Hk669@users.noreply.github.com> Co-authored-by: Li Jiang --- autogen/oai/anthropic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen/oai/anthropic.py b/autogen/oai/anthropic.py index 8ed6f909e6bc..7bb4608bd258 100644 --- a/autogen/oai/anthropic.py +++ b/autogen/oai/anthropic.py @@ -314,7 +314,7 @@ def oai_messages_to_anthropic_messages(params: Dict[str, Any]) -> list[dict[str, last_tool_result_index = -1 for message in params["messages"]: if message["role"] == "system": - params["system"] = message["content"] + params["system"] = params.get("system", "") + (" " if "system" in params else "") + message["content"] else: # New messages will be added here, manage role alternations expected_role = "user" if len(processed_messages) % 2 == 0 else "assistant"