cartertemm / AI-content-describer

NVDA add-on that provides descriptions for controls and images, powered by GPT4
GNU General Public License v2.0
48 stars 24 forks source link

Read Operation Timing Out #3

Closed aaronr7734 closed 11 months ago

aaronr7734 commented 11 months ago

Hi! I decided it would be more beneficial if I didn't spam the audiogames.net forum with more observations / reports and took things to more official channels. :)

Anyway, I've set my "Seconds to wait for a response before timing out" setting to 40. However, my requests are still timing out in about 15-17 seconds.

When this happens, I receive the following error:

Traceback (most recent call last):
  File "wx\core.pyc", line 3407, in <lambda>
  File "C:\Users\aaron\AppData\Roaming\nvda\addons\AI Content Describer\globalPlugins\AIContentDescriber\__init__.py", line 167, in describe_screenshot
    return self.describe_image(file, delete=True)
  File "C:\Users\aaron\AppData\Roaming\nvda\addons\AI Content Describer\globalPlugins\AIContentDescriber\__init__.py", line 204, in describe_image
    message = service.process(file, **ch.config[service.name])
  File "C:\Users\aaron\AppData\Roaming\nvda\addons\AI Content Describer\globalPlugins\AIContentDescriber\description_service.py", line 157, in process
    response = post(url="https://api.openai.com/v1/chat/completions", headers=headers, data=json.dumps(payload).encode('utf-8'), timeout=timeout)
  File "C:\Users\aaron\AppData\Roaming\nvda\addons\AI Content Describer\globalPlugins\AIContentDescriber\description_service.py", line 68, in post
    response=urllib.request.urlopen(request, timeout=15).read()
  File "urllib\request.pyc", line 222, in urlopen
  File "urllib\request.pyc", line 525, in open
  File "urllib\request.pyc", line 543, in _open
  File "urllib\request.pyc", line 503, in _call_chain
  File "urllib\request.pyc", line 1393, in https_open
  File "urllib\request.pyc", line 1353, in do_open
  File "http\client.pyc", line 1369, in getresponse
  File "http\client.pyc", line 310, in begin
  File "http\client.pyc", line 271, in _read_status
  File "socket.pyc", line 589, in readinto
  File "ssl.pyc", line 1071, in recv_into
  File "ssl.pyc", line 929, in read
socket.timeout: The read operation timed out

I've set my timeout time really high because barring things actually breaking, I don't want to ever waste API credits by having software give up waiting for a response, especially if the response might almost be done generating.

cartertemm commented 11 months ago

@aaronr7734 thanks for bringing this to my attention. Turns out I forgot to un-hardcode that value when config support was added in, which is why you weren't noticing much of a difference upon changing it. :grimacing:

Either way, I addressed it a couple minutes ago. If you feel comfortable building the add-on with scons and run into trouble, feel free to reopen this issue.