From 6acda2e6eccd161f285735f280a3aacc8e95124a Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 13 Feb 2025 00:40:04 -0800 Subject: [PATCH] refac: code interpreter --- backend/open_webui/utils/middleware.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 8294c21aa..4d70ddd65 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -1704,10 +1704,12 @@ async def process_chat_response( "stdout": "Code interpreter engine not configured." } + log.debug(f"Code interpreter output: {output}") + if isinstance(output, dict): stdout = output.get("stdout", "") - if stdout: + if isinstance(stdout, str): stdoutLines = stdout.split("\n") for idx, line in enumerate(stdoutLines): if "data:image/png;base64" in line: @@ -1739,7 +1741,7 @@ async def process_chat_response( result = output.get("result", "") - if result: + if isinstance(result, str): resultLines = result.split("\n") for idx, line in enumerate(resultLines): if "data:image/png;base64" in line: @@ -1789,6 +1791,8 @@ async def process_chat_response( } ) + print(content_blocks, serialize_content_blocks(content_blocks)) + try: res = await generate_chat_completion( request,