openai-python
openai-python copied to clipboard
Getting requests.exceptions.ChunkedEncodingError when using TaskCompletion in stream mode or
Describe the bug
Hi,
I'm using the openaI python module and I'm experiencing some issues lately. I'm making a streaming completion task. Randomly I'm getting the following exception "requests.exceptions.ChunkedEncodingError : ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)".
def send_completion_task_stream(self):
prompt = """my prompt"""
response = self.completion_task.create(prompt=prompt, model=self.modal_name, stop=self.stop,
temperature=self.temperature,
top_p=self.top_p, frequency_penalty=self.frequency_penalty,
presence_penalty=self.presence_penalty,
max_tokens=3000,
stream=True
)
return response `
do you know what can cause this error ?
Thank you
Best regards
To Reproduce
1- Send a streaming completion task and put max-token to 3000 2 - The errors appears (but randomly)
Code snippets
No response
OS
macOs
Python version
Python 3.10
Library version
openai-python-0.26.1
same here, for me it happens in non-English content and not related to the max-token I guess bcs I was set to 500.
I'm having the same problem when making completions in spanish language.
I'm having the error more frequently lately. I'm using completions in French language.
The error is shown in the image :
Facing the same issues right now. I can see in the Sentry stack trace it looks as if the first exception that occurred was in the urllib3 library.

However, I got a 200 from openai

And i can see that the data received back from openai even includes the text for a generation.

Not sure why the error is happening only occasionally
Today is impossible to use the api. I'm getting the error over and over.
Any idea on what causing it ?
lol, maybe we need to migrate to Microsoft Azure for ChatGPT API..
Same error frequently lately. I'm using completions in Chinese.
The error is shown below :
......
same error here
same here. Anyone found a solution for it?
Same, every single request I've sent to gpt-4
for the last 2 days fails due to this chunked encoding error. Is there a way to recover from this state while streaming?
I believe this has been resolved; please let me know if that's not the case and we can reopen.