Problem getting the response status text in all exceptions
dbrewster opened this issue · 1 comments
In all of the following constructors to the exception, there is a error calling response.text:
async def _check_response_status_codes(self, response: Response) -> None:
if response.status_code in RETRY_STATUS_CODES:
raise MistralAPIStatusException.from_response(
response,
message=f"Status: {response.status_code}. Message: {response.text}",
)
elif 400 <= response.status_code < 500:
if response.stream:
await response.aread()
raise MistralAPIException.from_response(
response,
message=f"Status: {response.status_code}. Message: {response.text}",
)
elif response.status_code >= 500:
if response.stream:
await response.aread()
raise MistralException(
message=f"Status: {response.status_code}. Message: {response.text}",
)
File "/Users/apple/opt/anaconda3/envs/rena-sanic-39/lib/python3.9/site-packages/mistralai/client_base.py", line 137, in _check_response_status_codes
message=f"Status: {response.status_code}. Message: {response.text}",
File "/Users/apple/opt/anaconda3/envs/rena-sanic-39/lib/python3.9/site-packages/httpx/_models.py", line 573, in text
content = self.content
File "/Users/apple/opt/anaconda3/envs/rena-sanic-39/lib/python3.9/site-packages/httpx/_models.py", line 567, in content
raise ResponseNotRead()
httpx.ResponseNotRead: Attempted to access streaming response content, without having called read()
.
This should be fixed. Could you try mistralai 1.0.0 and let us know if you still see the issue? Thanks!