From d8f71e1d7ff8fbe8e2a79c91bdb6e58ff27f6ace Mon Sep 17 00:00:00 2001 From: smonux Date: Thu, 26 Sep 2024 22:02:56 +0200 Subject: [PATCH] Some models produce almost correct json during function calling, but with additional data before of after it. This solves it. --- backend/open_webui/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 4af48906b..dadae0e04 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -440,6 +440,7 @@ async def chat_completion_tools_handler( if not content: return body, {} + content = content[content.find("{") : content.rfind("}") + 1] result = json.loads(content) tool_function_name = result.get("name", None)