Skip to content

The agent engineering platform.

partners[anthropic]: fix anthropic chat model message type lookup keys (#19034)

Maxime Perrin5ac0d1f67b4e
diff --git a/libs/partners/anthropic/langchain_anthropic/chat_models.py b/libs/partners/anthropic/langchain_anthropic/chat_models.py
index 6b2aa154e0..ef09aa3799 100644
--- a/libs/partners/anthropic/langchain_anthropic/chat_models.py
+++ b/libs/partners/anthropic/langchain_anthropic/chat_models.py
@@ -56,7 +56,12 @@ from langchain_core.utils.function_calling import convert_to_openai_tool
from langchain_anthropic.output_parsers import ToolsOutputParser
-_message_type_lookups = {"human": "user", "ai": "assistant"}
+_message_type_lookups = {
+ "human": "user",
+ "ai": "assistant",
+ "AIMessageChunk": "assistant",
+ "HumanMessageChunk": "user",
+}
def _format_image(image_url: str) -> Dict: