From 9677144015789da45cdf94ae150118df65db6f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=86=E8=90=8C=E9=97=B7=E6=B2=B9=E7=93=B6?= <253605712@qq.com> Date: Tue, 7 Jan 2025 17:25:38 +0800 Subject: [PATCH] fix:deepseek tool call not working correctly (#12437) --- .../model_providers/openai_api_compatible/llm/llm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py b/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py index 734cf28b15..2fd0c4ec1f 100644 --- a/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py +++ b/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py @@ -377,7 +377,10 @@ class OAIAPICompatLargeLanguageModel(_CommonOaiApiCompat, LargeLanguageModel): for tool in tools: formatted_tools.append(helper.dump_model(PromptMessageFunction(function=tool))) - data["tools"] = formatted_tools + if prompt_messages[-1].role.value == "tool": + data["tools"] = None + else: + data["tools"] = formatted_tools if stop: data["stop"] = stop