refac
This commit is contained in:
@@ -2313,7 +2313,12 @@ You have access to a Python code interpreter via: `<code_interpreter type="code"
|
|||||||
Ensure the code interpreter is effectively utilized to achieve the highest-quality analysis for the user."""
|
Ensure the code interpreter is effectively utilized to achieve the highest-quality analysis for the user."""
|
||||||
|
|
||||||
# Appended to the code interpreter prompt only when engine is pyodide (not jupyter)
|
# Appended to the code interpreter prompt only when engine is pyodide (not jupyter)
|
||||||
CODE_INTERPRETER_PYODIDE_FS_PROMPT = """
|
CODE_INTERPRETER_PYODIDE_PROMPT = """
|
||||||
|
|
||||||
|
##### Pyodide Environment
|
||||||
|
|
||||||
|
- This Python environment runs via Pyodide in the browser. **Do not install packages** — `pip install`, `subprocess`, and `micropip.install()` are not available.
|
||||||
|
- If a required library is unavailable, use an alternative approach with available modules. Do not attempt to install anything.
|
||||||
|
|
||||||
##### Persistent File System
|
##### Persistent File System
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ from open_webui.config import (
|
|||||||
DEFAULT_VOICE_MODE_PROMPT_TEMPLATE,
|
DEFAULT_VOICE_MODE_PROMPT_TEMPLATE,
|
||||||
DEFAULT_TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE,
|
DEFAULT_TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE,
|
||||||
DEFAULT_CODE_INTERPRETER_PROMPT,
|
DEFAULT_CODE_INTERPRETER_PROMPT,
|
||||||
CODE_INTERPRETER_PYODIDE_FS_PROMPT,
|
CODE_INTERPRETER_PYODIDE_PROMPT,
|
||||||
CODE_INTERPRETER_BLOCKED_MODULES,
|
CODE_INTERPRETER_BLOCKED_MODULES,
|
||||||
)
|
)
|
||||||
from open_webui.env import (
|
from open_webui.env import (
|
||||||
@@ -2378,7 +2378,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||||||
|
|
||||||
# Append filesystem awareness only for pyodide engine
|
# Append filesystem awareness only for pyodide engine
|
||||||
if engine != "jupyter":
|
if engine != "jupyter":
|
||||||
prompt += CODE_INTERPRETER_PYODIDE_FS_PROMPT
|
prompt += CODE_INTERPRETER_PYODIDE_PROMPT
|
||||||
|
|
||||||
form_data["messages"] = add_or_update_user_message(
|
form_data["messages"] = add_or_update_user_message(
|
||||||
prompt,
|
prompt,
|
||||||
@@ -2389,7 +2389,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||||||
# filesystem context into messages for pyodide engine
|
# filesystem context into messages for pyodide engine
|
||||||
if engine != "jupyter":
|
if engine != "jupyter":
|
||||||
form_data["messages"] = add_or_update_user_message(
|
form_data["messages"] = add_or_update_user_message(
|
||||||
CODE_INTERPRETER_PYODIDE_FS_PROMPT,
|
CODE_INTERPRETER_PYODIDE_PROMPT,
|
||||||
form_data["messages"],
|
form_data["messages"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user