diff --git a/backend/open_webui/tools/builtin.py b/backend/open_webui/tools/builtin.py index fe20555f9..b438759e1 100644 --- a/backend/open_webui/tools/builtin.py +++ b/backend/open_webui/tools/builtin.py @@ -429,6 +429,9 @@ async def execute_code( "session_id": ( __metadata__.get("session_id") if __metadata__ else None ), + "files": ( + __metadata__.get("files", []) if __metadata__ else [] + ), }, } ) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 1f2718ae7..a4ca8c356 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -4510,6 +4510,7 @@ async def streaming_chat_response_handler(response, ctx): "session_id": metadata.get( "session_id", None ), + "files": metadata.get("files", []), }, } ) diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index 5a0f899ff..61ecb75c8 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -1679,6 +1679,10 @@ export const renderVegaVisualization = async (spec: string, i18n?: any) => { }; export const getCodeBlockContents = (content: string): object => { + // Strip thinking/reasoning and other detail blocks before extracting code + // to prevent code inside
from being treated as artifacts + content = removeAllDetails(content); + const codeBlockContents = content.match(/```[\s\S]*?```/g); let codeBlocks = [];