mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
fix(backend):处理不支持函数调用的模型
- 当收到 "Function call is not supported for this model." 错误消息时 - 移除所有 "tool" 类型的消息和包含 "tool_calls" 的消息 - 使用剩余的消息重新调用 AskAi函数
This commit is contained in:
parent
9a60736739
commit
378a5c47ba
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user