Hey All,
I have suddenly encountered an issue with my API request to DALL-E suddenly throwing a “Server Disconnected” when requesting anything.
It was working find maybe 2 days ago and since then it constantly disconnects
async def generate_image(userInput):
logger = logging.getLogger(__name__)
logger.debug("Generating image with input: %s", userInput)
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {OPENAI_KEY}'
}
data = {
'model': 'dall-e-3',
'prompt': userInput,
'size': '1024x1024',
'quality': 'hd',
'n': 1
}
try:
async with aiohttp.ClientSession() as session:
async with session.post('[https call here to/v1/images/generations]', headers=headers, json=data) as resp:
response_data = await resp.json()
logger.debug("Response data: %s", response_data)
if resp.status == 200:
image_url = response_data['data'][0]['url']
logger.info("Image URL: %s", image_url)
return image_url
else:
logger.error("Failed to generate image. Status: %s, Data: %s", resp.status, response_data)
return None
except Exception as e:
logger.exception("An error occurred while generating the image: %s", e)
return None
and the logging returned from making the subsequent request:
> Request: Flower
> DEBUG:NetworkAdapters.OpenAINetworkAdapter:Generating image with input: Flower
> ERROR:NetworkAdapters.OpenAINetworkAdapter:An error occurred while generating the image: Server disconnected
> Traceback (most recent call last):
> File C:\Users\...\NetworkAdapters\OpenAINetworkAdapter.py", line 109, in generate_image
> async with session.post('https://api.openai.com/v1/images/generations', headers=headers, json=data) as resp:
> File C:\Users\...\Python\Lib\site-packages\aiohttp\client.py", line 1141, in __aenter__
> self._resp = await self._coro
> ^^^^^^^^^^^^^^^^
> File "C:\Users\...\Python\Lib\site-packages\aiohttp\client.py", line 560, in _request
> await resp.start(conn)
> File "C:\Users\...\Python\Lib\site-packages\aiohttp\client_reqrep.py", line 899, in start
> message, payload = await protocol.read() # type: ignore[union-attr]
> ^^^^^^^^^^^^^^^^^^^^^
> File "C:\Users\...\Python\Lib\site-packages\aiohttp\streams.py", line 616, in read
> await self._waiter
> aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected
> Response: None
I’m posting this mostly because I am totally baffled as to what changed. I have a request using slash commands (fails) and prefix commands (fails) both of which use the request above and fails with server disconnected
everytime