Skip to content

The agent engineering platform.

community[patch]: Fix message formatting for Anthropic models on Amazon Bedrock (#20801)

Nestor Qin9111d3a6369d
diff --git a/libs/community/langchain_community/chat_models/bedrock.py b/libs/community/langchain_community/chat_models/bedrock.py
index 74eb1af216..852eb0091f 100644
--- a/libs/community/langchain_community/chat_models/bedrock.py
+++ b/libs/community/langchain_community/chat_models/bedrock.py
@@ -193,7 +193,13 @@ class ChatPromptAdapter:
)
-_message_type_lookups = {"human": "user", "ai": "assistant"}
+_message_type_lookups = {
+ "human": "user",
+ "ai": "assistant",
+ "AIMessageChunk": "assistant",
+ "HumanMessageChunk": "user",
+ "function": "user",
+}
@deprecated(