mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-24 07:35:18 +00:00
community[patch]: fix bug in cohere that async for
a coroutine in ChatCohere (#19381)
Without `await`, the `stream` returned from the `async_client` is actually a coroutine, which could not be used in `async for`.
This commit is contained in:
parent
1adaa3c662
commit
9c4b6dc979
@ -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":
|
||||
|
Loading…
Reference in New Issue
Block a user