-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixed in v1Issues addressed by the v1 betaIssues addressed by the v1 beta
Description
Describe the bug
Streaming output from gpt4 consistently fails with Connection broken: InvalidChunkLength(got length b'', 0 bytes read)
for prompts that trigger long-form responses. I've been able to reproduce this by prompting gpt to rewrite a long document.
A few observations
- This failure occurs exactly at the 5 minute mark every time, which leads me to believe there's a timeout somewhere.
- The python implementation of stream reader assumes that an empty string will never be returned by the server.
- I sent the same request using a non-streaming client with a timeout at 10min. The timeout wasn't triggered until the 10min mark,so this problem seems isolated to streaming
Code snippet from urllib3/response.py
:
def _update_chunk_length(self):
# First, we'll figure out length of a chunk and then
# we'll try to read it from socket.
if self.chunk_left is not None:
return
line = self._fp.fp.readline() # self._fp.fp.readline() returns b''
line = line.split(b";", 1)[0]
try:
self.chunk_left = int(line, 16) # this raises a value error
except ValueError:
# Invalid chunked protocol response, abort.
self.close()
raise InvalidChunkLength(self, line)
It seems like a problem on the server side but Im not confident
To Reproduce
- Create gpt4 streaming client
- Prompt it to rewrite a very long text. For example, verses 1:1 -> 4:10 in the book of genesis
Code snippets
No response
OS
macOs
Python version
Python 3.10.9
Library version
v.0.26.4
karim-attia, shunwen, givery-mo, elh, t4ng and 7 more
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixed in v1Issues addressed by the v1 betaIssues addressed by the v1 beta