Browse Source

refac: code interpreter

Timothy Jaeryang Baek 2 months ago
parent
commit
6acda2e6ec
1 changed files with 6 additions and 2 deletions
  1. 6 2
      backend/open_webui/utils/middleware.py

+ 6 - 2
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,