Skip to content

Commit 6acda2e

Browse files
committed
refac: code interpreter
1 parent 6d899b8 commit 6acda2e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

backend/open_webui/utils/middleware.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,10 +1704,12 @@ async def stream_body_handler(response):
17041704
"stdout": "Code interpreter engine not configured."
17051705
}
17061706

1707+
log.debug(f"Code interpreter output: {output}")
1708+
17071709
if isinstance(output, dict):
17081710
stdout = output.get("stdout", "")
17091711

1710-
if stdout:
1712+
if isinstance(stdout, str):
17111713
stdoutLines = stdout.split("\n")
17121714
for idx, line in enumerate(stdoutLines):
17131715
if "data:image/png;base64" in line:
@@ -1739,7 +1741,7 @@ async def stream_body_handler(response):
17391741

17401742
result = output.get("result", "")
17411743

1742-
if result:
1744+
if isinstance(result, str):
17431745
resultLines = result.split("\n")
17441746
for idx, line in enumerate(resultLines):
17451747
if "data:image/png;base64" in line:
@@ -1789,6 +1791,8 @@ async def stream_body_handler(response):
17891791
}
17901792
)
17911793

1794+
print(content_blocks, serialize_content_blocks(content_blocks))
1795+
17921796
try:
17931797
res = await generate_chat_completion(
17941798
request,

0 commit comments

Comments
 (0)