OoriData / OgbujiPT

Client-side toolkit for using large language models, including where self-hosted
Apache License 2.0
103 stars 8 forks source link

handle a failure of the API (be that openai or a local machine) to respond #23

Open choccccy opened 1 year ago

choccccy commented 1 year ago
concurrent.futures.process._RemoteTraceback: 
""" 
Traceback (most recent call last): 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/urllib3/connectionpool.py", line 714, in urlopen 
httplib_response = self._make_request( 
^^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/urllib3/connectionpool.py", line 466, in _make_request 
six.raise_from(e, None) 
File "<string>", line 3, in raise_from 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/urllib3/connectionpool.py", line 461, in _make_request 
httplib_response = conn.getresponse() 
^^^^^^^^^^^^^^^^^^ 
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 1378, in getresponse 
response.begin() 
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 318, in begin 
version, status, reason = self._read_status() 
^^^^^^^^^^^^^^^^^^^ 
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 287, in _read_status 
raise RemoteDisconnected("Remote end closed connection without" 
http.client.RemoteDisconnected: Remote end closed connection without response 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/requests/adapters.py", line 486, in send 
resp = conn.urlopen( 
^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/urllib3/connectionpool.py", line 798, in urlopen 
retries = retries.increment( 
^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/urllib3/util/retry.py", line 550, in increment 
raise six.reraise(type(error), error, _stacktrace) 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/urllib3/packages/six.py", line 769, in reraise 
raise value.with_traceback(tb) 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/urllib3/connectionpool.py", line 714, in urlopen 
httplib_response = self._make_request( 
^^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/urllib3/connectionpool.py", line 466, in _make_request 
six.raise_from(e, None) 
File "<string>", line 3, in raise_from 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/urllib3/connectionpool.py", line 461, in _make_request 
httplib_response = conn.getresponse() 
^^^^^^^^^^^^^^^^^^ 
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 1378, in getresponse 
response.begin() 
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 318, in begin 
version, status, reason = self._read_status() 
^^^^^^^^^^^^^^^^^^^ 
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 287, in _read_status 
raise RemoteDisconnected("Remote end closed connection without" 
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/openai/api_requestor.py", line 596, in request_raw 
result = _thread_context.session.request( 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/requests/sessions.py", line 589, in request 
resp = self.send(prep, **send_kwargs) 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/requests/sessions.py", line 703, in send 
r = adapter.send(request, **kwargs) 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/requests/adapters.py", line 501, in send 
raise ConnectionError(err, request=request) 
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) 

The above exception was the direct cause of the following exception: 

Traceback (most recent call last): 
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/process.py", line 256, in _process_worker 
r = call_item.fn(*call_item.args, **call_item.kwargs) 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/ogbujipt/async_helper.py", line 70, in openai_api_surrogate 
return api_func(prompt=prompt, **trimmed_kwargs) 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/openai/api_resources/completion.py", line 25, in create 
return super().create(*args, **kwargs) 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create 
response, _, api_key = requestor.request( 
^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/openai/api_requestor.py", line 288, in request 
result = self.request_raw( 
^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/openai/api_requestor.py", line 609, in request_raw 
raise error.APIConnectionError( 
openai.error.APIConnectionError: Error communicating with OpenAI: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) 
""" 

The above exception was the direct cause of the following exception: 

Traceback (most recent call last): 
File "/Users/osi/dev/PS-ATC/pylib/sandbox_proto/app.py", line 158, in submitted 
results_dict = await sess.run_queries() 
^^^^^^^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/atc_ai/operation/__init__.py", line 135, in run_queries 
results = await asyncio.gather(*[q.operation.execute(self) for q in self.queries]) 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/atc_ai/operation/basic.py", line 67, in execute 
await sess.queue_llm_call(prompt, self.text, self) 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/atc_ai/operation/__init__.py", line 117, in queue_llm_call 
completion_dict = llm_call_obj.handle_completion() 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/atc_ai/llm_tools.py", line 79, in handle_completion 
response = self.task.result() 
^^^^^^^^^^^^^^^^^^ 
File "/Users/osi/.local/venv/atc/lib/python3.11/site-packages/ogbujipt/async_helper.py", line 39, in schedule_callable 
response = await loop.run_in_executor(executor, prepped_callable, *args) 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
openai.error.APIConnectionError: Error communicating with OpenAI: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
uogbuji commented 11 months ago

@choccccy I think this should have been sorted when we worked on reentrancy. Just checking: can this be closed? Do you remember the reproduction code?