From 850a70ce456452264a40fd8c476cbba35d350e09 Mon Sep 17 00:00:00 2001 From: Samuel Date: Sun, 3 Nov 2024 06:37:34 +0000 Subject: [PATCH] fix for qwen models --- backend/open_webui/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 6883d1d13..9f2d81940 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -579,8 +579,10 @@ async def handle_nonstreaming_response(request: Request, response: Response, is_ollama = True is_openai = not is_ollama + log.debug(f"smonux 1: { response_dict=} ") + while (is_ollama and "tool_calls" in response_dict.get("message", {})) or \ - (is_openai and response_dict["choices"][0]["finish_reason"] == "tool_calls"): + (is_openai and "tool_calls" in response_dict["choices"][0].get("message",{}) ): if is_ollama: message = response_dict.get("message", {}) tool_calls = message.get("tool_calls", [])