Error generating a image with the telegram-bot example (stablediffusion)
greygoo opened this issue · comments
LocalAI version:
quay.io/go-skynet/local-ai:v1.18.0-ffmpeg
rebuild with GO_TAGS=stablediffusion
Environment, CPU architecture, OS, and Version:
rtx4060/ryzen5700/32G
Describe the bug
NOTE: The bug did not appear when using a newer local ai container version. I'm in the process of retesting that and will create PR for the docker-compose.yml, once I'm sure an update fixes this, and does not break anything else.
When following the telegram-bot example instructions to set it up and the request an image to be generated by it, it throws an error instead:
An exception was raised while handling an update
update = {
"update_id": 399390716,
"message": {
"chat": {
"id": -1002163767786,
"type": "supergroup",
"title": "TSM-AI"
},
"text": "@Loriaai_bot a tree",
"group_chat_created": false,
"entities": [
{
"length": 12,
"type": "mention",
"offset": 0
}
],
"message_id": 1138,
"delete_chat_photo": false,
"date": 1719144876,
"supergroup_chat_created": false,
"channel_chat_created": false,
"from": {
"is_bot": false,
"username": "greyg00",
"first_name": "grey",
"last_name": "goo",
"id": 1271023244,
"language_code": "en"
}
}
}
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/openai/api_requestor.py", line 668, in arequest_raw
result = await session.request(**request_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 608, in _request
await resp.start(conn)
File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 976, in start
message, payload = await protocol.read() # type: ignore[union-attr]
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 640, in read
await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/telegram/ext/_application.py", line 1104, in process_update
await coroutine
File "/usr/local/lib/python3.11/site-packages/telegram/ext/_handler.py", line 141, in handle_update
return await self.callback(update, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/code/bot/bot.py", line 311, in message_handle
await generate_image_handle(update, context, message=message)
File "/code/bot/bot.py", line 500, in generate_image_handle
image_urls = await openai_utils.generate_images(message, n_images=config.return_n_generated_images, model=image_model)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/code/bot/openai_utils.py", line 161, in generate_images
r = await openai.Image.acreate(prompt=prompt, n=n_images, size="512x512", model=model)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/api_resources/image.py", line 76, in acreate
response, _, api_key = await requestor.arequest(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/api_requestor.py", line 372, in arequest
result = await self.arequest_raw(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/api_requestor.py", line 685, in arequest_raw
raise error.APIConnectionError("Error communicating with OpenAI") from e
openai.error.APIConnectionError: Error communicating with OpenAI
To Reproduce
- follow the instructions in the examples for the telegram bot to set it up
- in telegram, ask it to generate a image
Expected behavior
A image is generated
Logs
Currently not having access as I'm running the fixed version, but will add, once I switch back to the non working version
Additional context
I can confirm, with the new container version, the issue does not appear anymore, will create PR for the docker-compose.yml
thank you @greygoo !