openai-python icon indicating copy to clipboard operation
openai-python copied to clipboard

Getting requests.exceptions.ChunkedEncodingError when using TaskCompletion in stream mode or

Open WalidAxo opened this issue 2 years ago • 5 comments

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

WalidAxo avatar Feb 09 '23 17:02 WalidAxo

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.

R0uter avatar Feb 14 '23 07:02 R0uter

I'm having the same problem when making completions in spanish language.

javi111717 avatar Feb 14 '23 11:02 javi111717

I'm having the error more frequently lately. I'm using completions in French language.

The error is shown in the image : image

WalidAxo avatar Feb 14 '23 14:02 WalidAxo

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.

image

However, I got a 200 from openai

image

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

image

Not sure why the error is happening only occasionally

spelsbergsam avatar Feb 14 '23 15:02 spelsbergsam

Today is impossible to use the api. I'm getting the error over and over.

Any idea on what causing it ?

WalidAxo avatar Feb 15 '23 13:02 WalidAxo

lol, maybe we need to migrate to Microsoft Azure for ChatGPT API..

ArtemBernatskyy avatar Apr 25 '23 16:04 ArtemBernatskyy

Same error frequently lately. I'm using completions in Chinese. The error is shown below : image ...... image

firezym avatar May 10 '23 12:05 firezym

same error here

yannoth avatar May 10 '23 14:05 yannoth

same here. Anyone found a solution for it?

aditivin avatar May 16 '23 19:05 aditivin

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?

benjaminb avatar May 21 '23 14:05 benjaminb

I believe this has been resolved; please let me know if that's not the case and we can reopen.

rattrayalex avatar Dec 31 '23 00:12 rattrayalex