Skip to content

Commit

Permalink
Folding code execution effect message block
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaopa233 committed Oct 8, 2024
1 parent 9c529f3 commit 6e8493f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions open-webui/tools/run_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<details>\n<summary>Code Execution</summary>\nI executed the following {language} code:\n```{language}\n{code}\n```\n```Output\n{output.strip()}\n```\n</details>\n"
)
if output:
output = output.strip()
if debug:
Expand All @@ -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<details>\n<summary>Code Execution</summary>\nI executed the following {language} code:\n```{language}\n{code}\n```\n```Output\n{output}\n```\n</details>\n"
)

return {
"status": status,
"output": output,
Expand Down
8 changes: 3 additions & 5 deletions src/openwebui/tools/run_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<details>\n<summary>Code Execution</summary>\nI executed the following {language} code:\n```{language}\n{code}\n```\n```Output\n{output.strip()}\n```\n</details>\n"
)
if output:
output = output.strip()
if debug:
Expand All @@ -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<details>\n<summary>Code Execution</summary>\nI executed the following {language} code:\n```{language}\n{code}\n```\n```Output\n{output}\n```\n</details>\n"
)

return {
"status": status,
"output": output,
Expand Down

0 comments on commit 6e8493f

Please sign in to comment.