Merge branch 'master' of stage.fjerkroa.no:Fjerkroa/discord_bot

This commit is contained in:
Fjerkroa Auto 2023-11-14 10:27:29 +01:00
commit a2c7aec1e3

View File

@ -190,7 +190,7 @@ class AIResponder(object):
) as response: ) as response:
response = await response.json() response = await response.json()
if "sdGenerationJob" not in response: if "sdGenerationJob" not in response:
logging.warning(f"No 'sdGenerationJob' found in response: {repr(response)}") logging.warning(f"No 'sdGenerationJob' found in response, sleep for {error_sleep}s: {repr(response)}")
await asyncio.sleep(error_sleep) await asyncio.sleep(error_sleep)
continue continue
generation_id = response["sdGenerationJob"]["generationId"] generation_id = response["sdGenerationJob"]["generationId"]
@ -201,7 +201,7 @@ class AIResponder(object):
) as response: ) as response:
response = await response.json() response = await response.json()
if "generations_by_pk" not in response: if "generations_by_pk" not in response:
logging.warning(f"Unexpected response: {repr(response)}") logging.warning(f"Unexpected response, sleep for {error_sleep}s: {repr(response)}")
await asyncio.sleep(error_sleep) await asyncio.sleep(error_sleep)
continue continue
if len(response["generations_by_pk"]["generated_images"]) == 0: if len(response["generations_by_pk"]["generated_images"]) == 0:
@ -218,9 +218,10 @@ class AIResponder(object):
logging.info(f'Drawed a picture with leonardo AI on this description: {repr(description)}') logging.info(f'Drawed a picture with leonardo AI on this description: {repr(description)}')
return image_bytes return image_bytes
except Exception as err: except Exception as err:
logging.warning(f"Failed to generate image: {repr(description)}\n{repr(err)}") logging.warning(f"Failed to generate image, sleep for {error_sleep}s: {repr(description)}\n{repr(err)}")
else: else:
logging.warning(f"Failed to generate image: {repr(description)}") logging.warning(f"Failed to generate image, sleep for {error_sleep}s: {repr(description)}")
await asyncio.sleep(error_sleep)
raise RuntimeError(f"Failed to generate image {repr(description)}") raise RuntimeError(f"Failed to generate image {repr(description)}")
async def post_process(self, message: AIMessage, response: Dict[str, Any]) -> AIResponse: async def post_process(self, message: AIMessage, response: Dict[str, Any]) -> AIResponse: