-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
I am doing a hundreds of requests by hour, 95% works perfectly.
Sometimes it crashes with this error:
openai.InternalServerError: upstream connect error or disconnect/reset before headers. reset reason: connection failure, transport failure reason: delayed connect error: 111
The thing is that the same code works most of the time and fails sometime, making the debugging really hard, I failed to find the pattern that make theses requests fail, it can arrive anytime.
It can pass with big requests, with a lot of requests at the same time. It can crash with tiny request and with few requests in the same time.
So the intuition that they are too much request or too big request seems wrong.
I have this Traceback:
return func(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^\n File "/usr/local/lib/python3.11/site-packages/openai/resources/chat/completions.py", line 650, in create\n return self._post(\n ^^^^^^^^^^^\n File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1259, in post\n return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 936, in request\n return self._request(\n ^^^^^^^^^^^^^^\n File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1025, in _request\n return self._retry_request(\n ^^^^^^^^^^^^^^^^^^^^\n File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1074, in _retry_request\n return self._request(\n ^^^^^^^^^^^^^^\n File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1025, in _request\n return self._retry_request(\n ^^^^^^^^^^^^^^^^^^^^\n File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1074, in _retry_request\n return self._request(\n ^^^^^^^^^^^^^^\n File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1040, in _request\n raise self._make_status_error_from_response(err.response) from None\nopenai.InternalServerError: upstream connect error or disconnect/reset before headers. reset reason: connection failure, transport failure reason: delayed connect error: 111\n
To Reproduce
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-4o",
temperature=0,
max_tokens=None,
timeout=None,
max_retries=2,
)
Code snippets
No response
OS
Linux
Python version
python v3.11
Library version
openai v1.35.10