From 378a5c47bad0e99f1610f92b708c57b6ccb58422 Mon Sep 17 00:00:00 2001 From: ArvinLovegood Date: Wed, 2 Jul 2025 18:46:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(backend):=E5=A4=84=E7=90=86=E4=B8=8D?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=87=BD=E6=95=B0=E8=B0=83=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 当收到 "Function call is not supported for this model." 错误消息时 - 移除所有 "tool" 类型的消息和包含 "tool_calls" 的消息 - 使用剩余的消息重新调用 AskAi函数 --- backend/data/openai_api.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/data/openai_api.go b/backend/data/openai_api.go index 9a77f33..952b8ee 100644 --- a/backend/data/openai_api.go +++ b/backend/data/openai_api.go @@ -1045,7 +1045,17 @@ func AskAiWithTools(o OpenAi, err error, messages []map[string]interface{}, ch c } if msg == "Function call is not supported for this model." { - AskAi(o, err, messages, ch, question) + var newMessages []map[string]any + for _, message := range messages { + if message["role"] == "tool" { + continue + } + if _, ok := message["tool_calls"]; ok { + continue + } + newMessages = append(newMessages, message) + } + AskAi(o, err, newMessages, ch, question) } else { ch <- map[string]any{ "code": 0,