Skip to content

The agent engineering platform.

community[patch]: fix bug in cohere that `async for` a coroutine in ChatCohere (#19381)

kaijietti9c4b6dc979ed
diff --git a/libs/community/langchain_community/chat_models/cohere.py b/libs/community/langchain_community/chat_models/cohere.py
index 07718c7f79..2ea44328a7 100644
--- a/libs/community/langchain_community/chat_models/cohere.py
+++ b/libs/community/langchain_community/chat_models/cohere.py
@@ -172,9 +172,9 @@ class ChatCohere(BaseChatModel, BaseCohere):
request = get_cohere_chat_request(messages, **self._default_params, **kwargs)
if hasattr(self.async_client, "chat_stream"): # detect and support sdk v5
- stream = self.async_client.chat_stream(**request)
+ stream = await self.async_client.chat_stream(**request)
else:
- stream = self.async_client.chat(**request, stream=True)
+ stream = await self.async_client.chat(**request, stream=True)
async for data in stream:
if data.event_type == "text-generation":