Skip to content

The agent engineering platform.

groq[patch]: Make stream robust to ToolMessage (#20417)

ccurme4b6b0a87b6e4
diff --git a/libs/partners/groq/langchain_groq/chat_models.py b/libs/partners/groq/langchain_groq/chat_models.py
index 5b58b36e6e..61fecd7b46 100644
--- a/libs/partners/groq/langchain_groq/chat_models.py
+++ b/libs/partners/groq/langchain_groq/chat_models.py
@@ -287,7 +287,7 @@ class ChatGroq(BaseChatModel):
"id": rtc.get("id"),
"index": rtc.get("index"),
}
- for rtc in message.additional_kwargs["tool_calls"]
+ for rtc in message.additional_kwargs.get("tool_calls", [])
]
chunk_ = ChatGenerationChunk(
message=AIMessageChunk(
@@ -358,7 +358,7 @@ class ChatGroq(BaseChatModel):
"id": rtc.get("id"),
"index": rtc.get("index"),
}
- for rtc in message.additional_kwargs["tool_calls"]
+ for rtc in message.additional_kwargs.get("tool_calls", [])
]
chunk_ = ChatGenerationChunk(
message=AIMessageChunk(