Skip to content

Commit 7c43499

Browse files
Format printed console outputs from code interpreter with '> ' prefix
1 parent 2817776 commit 7c43499

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

routers/chat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,11 @@ async def handle_assistant_stream(
228228
if tool_call.code_interpreter and tool_call.code_interpreter.outputs:
229229
for output in tool_call.code_interpreter.outputs:
230230
if output.type == "logs" and output.logs:
231+
# Replace "\n" in the logs with "\n> " to format it as console output
232+
output_logs = "\n\n> " + str(output.logs).strip().replace("\n", "\n> ")
231233
yield sse_format(
232234
"toolDelta",
233-
wrap_for_oob_swap(step_id, str(output.logs))
235+
wrap_for_oob_swap(step_id, output_logs)
234236
)
235237
elif output.type == "image" and output.image and output.image.file_id:
236238
logger.debug(f"Image Output - File ID: {output.image.file_id}")

0 commit comments

Comments
 (0)