From 17b71059b5f4c189233f24e69f408d94c14c3c84 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Sun, 1 Jan 2023 06:19:23 +0000 Subject: [PATCH] Format Python code with psf/black push --- models/openai_model.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/models/openai_model.py b/models/openai_model.py index eb5a017a..8df1b5cd 100644 --- a/models/openai_model.py +++ b/models/openai_model.py @@ -444,7 +444,10 @@ async def send_image_request(self, prompt, vary=None) -> tuple[File, list[Any]]: # For each image url, open it as an image object using PIL images = await asyncio.get_running_loop().run_in_executor( - None, lambda: [Image.open(requests.get(url, stream=True).raw) for url in image_urls] + None, + lambda: [ + Image.open(requests.get(url, stream=True).raw) for url in image_urls + ], ) # Save all the images with a random name to self.IMAGE_SAVE_PATH @@ -504,7 +507,9 @@ async def send_image_request(self, prompt, vary=None) -> tuple[File, list[Any]]: # Save the new_im to a temporary file and return it as a discord.File temp_file = tempfile.NamedTemporaryFile(suffix=".png", delete=False) - await asyncio.get_running_loop().run_in_executor(None, new_im.save, temp_file.name) + await asyncio.get_running_loop().run_in_executor( + None, new_im.save, temp_file.name + ) # Print the filesize of new_im, in mega bytes image_size = os.path.getsize(temp_file.name) / 1000000 @@ -522,11 +527,16 @@ async def send_image_request(self, prompt, vary=None) -> tuple[File, list[Any]]: # We want to do this resizing asynchronously, so that it doesn't block the main thread during the resize. # We can use the asyncio.run_in_executor method to do this new_im = await asyncio.get_running_loop().run_in_executor( - None, functools.partial(new_im.resize, (int(new_im.width / 1.05), int(new_im.height / 1.05))) + None, + functools.partial( + new_im.resize, (int(new_im.width / 1.05), int(new_im.height / 1.05)) + ), ) temp_file = tempfile.NamedTemporaryFile(suffix=".png", delete=False) - await asyncio.get_running_loop().run_in_executor(None, new_im.save, temp_file.name) + await asyncio.get_running_loop().run_in_executor( + None, new_im.save, temp_file.name + ) image_size = os.path.getsize(temp_file.name) / 1000000 print(f"New image size is {image_size}MB")