Improve exponantial back off on leanardo drawing a bit, and log the sleeps.
This commit is contained in:
parent
95bc6ce041
commit
924daf134f
@ -184,7 +184,7 @@ class AIResponder(object):
|
||||
) as response:
|
||||
response = await response.json()
|
||||
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)
|
||||
continue
|
||||
generation_id = response["sdGenerationJob"]["generationId"]
|
||||
@ -195,7 +195,7 @@ class AIResponder(object):
|
||||
) as response:
|
||||
response = await response.json()
|
||||
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)
|
||||
continue
|
||||
if len(response["generations_by_pk"]["generated_images"]) == 0:
|
||||
@ -212,9 +212,10 @@ class AIResponder(object):
|
||||
logging.info(f'Drawed a picture with leonardo AI on this description: {repr(description)}')
|
||||
return image_bytes
|
||||
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:
|
||||
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)}")
|
||||
|
||||
async def post_process(self, message: AIMessage, response: Dict[str, Any]) -> AIResponse:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user