Просмотр исходного кода

Some models produce almost correct json during function calling, but with additional data before of after it. This solves it.

smonux 7 месяцев назад
Родитель
Сommit
d8f71e1d7f
1 измененных файлов с 1 добавлено и 0 удалено
  1. 1 0
      backend/open_webui/main.py

+ 1 - 0
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)