From 5e253d6cf946fc7812e2306a17fc738c2dfa0054 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 20:03:26 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../jupyter_ai_magics/providers.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/jupyter-ai-magics/jupyter_ai_magics/providers.py b/packages/jupyter-ai-magics/jupyter_ai_magics/providers.py index f75e0c3bc..baff893a9 100644 --- a/packages/jupyter-ai-magics/jupyter_ai_magics/providers.py +++ b/packages/jupyter-ai-magics/jupyter_ai_magics/providers.py @@ -658,7 +658,7 @@ def _call( ) try: - if "generated_text" in str(response): + if "generated_text" in str(response): # text2 text or text-generation task response_text = json.loads(response.decode())[0]["generated_text"] # Maybe the generation has stopped at one of the stop sequences: @@ -685,10 +685,13 @@ def _call( buffer = io.BytesIO() image.save(buffer, format=imageFormat) # # Encode image data to Base64 bytes, then decode bytes to str - return mimeType + ";base64," + base64.b64encode(buffer.getvalue()).decode() - except: - raise ValueError("Task not supported, only text-generation and text-to-image tasks are valid.") - + return ( + mimeType + ";base64," + base64.b64encode(buffer.getvalue()).decode() + ) + except: + raise ValueError( + "Task not supported, only text-generation and text-to-image tasks are valid." + ) async def _acall(self, *args, **kwargs) -> Coroutine[Any, Any, str]: return await self._call_in_executor(*args, **kwargs)