From 6e8493fe118c216e20f10420a3aa534d977839d8 Mon Sep 17 00:00:00 2001 From: xiaopa233 Date: Tue, 8 Oct 2024 15:16:58 +0800 Subject: [PATCH] Folding code execution effect message block --- open-webui/tools/run_code.py | 8 +++----- src/openwebui/tools/run_code.py | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/open-webui/tools/run_code.py b/open-webui/tools/run_code.py index 5165320..4e273b0 100644 --- a/open-webui/tools/run_code.py +++ b/open-webui/tools/run_code.py @@ -299,6 +299,9 @@ async def _fail(error_message, status="SANDBOX_ERROR"): ) status = "OK" output = result.stdout or result.stderr + await emitter.message( + f"\n
\nCode Execution\nI executed the following {language} code:\n```{language}\n{code}\n```\n```Output\n{output.strip()}\n```\n
\n" + ) if output: output = output.strip() if debug: @@ -316,11 +319,6 @@ def _log(filename: str, log_line: str): done=True, description=f"[DEBUG MODE] status={status}; output={output}; valves=[{valves}]; debug={per_file_logs}", ) - - await emitter.message( - f"\n
\nCode Execution\nI executed the following {language} code:\n```{language}\n{code}\n```\n```Output\n{output}\n```\n
\n" - ) - return { "status": status, "output": output, diff --git a/src/openwebui/tools/run_code.py b/src/openwebui/tools/run_code.py index f0e7520..b706dc6 100644 --- a/src/openwebui/tools/run_code.py +++ b/src/openwebui/tools/run_code.py @@ -252,6 +252,9 @@ async def _fail(error_message, status="SANDBOX_ERROR"): ) status = "OK" output = result.stdout or result.stderr + await emitter.message( + f"\n
\nCode Execution\nI executed the following {language} code:\n```{language}\n{code}\n```\n```Output\n{output.strip()}\n```\n
\n" + ) if output: output = output.strip() if debug: @@ -269,11 +272,6 @@ def _log(filename: str, log_line: str): done=True, description=f"[DEBUG MODE] status={status}; output={output}; valves=[{valves}]; debug={per_file_logs}", ) - - await emitter.message( - f"\n
\nCode Execution\nI executed the following {language} code:\n```{language}\n{code}\n```\n```Output\n{output}\n```\n
\n" - ) - return { "status": status, "output": output,