-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python client use async with stream not work! #61
Comments
read()
.read()
.
read()
.
Since you are trying to call the async client, you need to call it inside an async loo. Try encapsulating the call to |
Hmm.. I am getting this same error when using the async client to do function calling. Works just fine up until a function response is sent.. then throws this httpx.ResponseNotRead error. Specifically this happens when I'm trying to iterate over the response using an I am running inside an async function. |
Which version of I am able to run the following code snippet below with no errors on v0.0.11 through to v0.1.6. import asyncio
import os
from mistralai.async_client import MistralAsyncClient
from mistralai.models.chat_completion import ChatMessage
api_key = os.environ["MISTRAL_API_KEY"]
model = "mistral-large-latest"
client = MistralAsyncClient(api_key=api_key)
messages = [ChatMessage(role="user", content="What is the best French cheese?")]
# With async
async_response = client.chat_stream(model=model, messages=messages)
async def main():
async for chunk in async_response:
print(chunk.choices[0].delta.content)
# Run the async function
asyncio.run(main())
|
I was using latest, but it turned out that there was an error in my message syntax that was being bubbled up this way. The error message I received was a bit of a red herring. |
I use python client
use the code from document , use stream and async
It raise :
httpx.ResponseNotRead: Attempted to access streaming response content, without having called
read().
The text was updated successfully, but these errors were encountered: