mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-25 08:03:39 +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)
|
request = get_cohere_chat_request(messages, **self._default_params, **kwargs)
|
||||||
|
|
||||||
if hasattr(self.async_client, "chat_stream"): # detect and support sdk v5
|
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:
|
else:
|
||||||
stream = self.async_client.chat(**request, stream=True)
|
stream = await self.async_client.chat(**request, stream=True)
|
||||||
|
|
||||||
async for data in stream:
|
async for data in stream:
|
||||||
if data.event_type == "text-generation":
|
if data.event_type == "text-generation":
|
||||||
|
Loading…
Reference in New Issue
Block a user