mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-19 09:46:39 +08:00
fixed bug for gpt-4-turbo-2024-0409 model function calls
This commit is contained in:
parent
cfe333e89f
commit
6efd92806f
@ -1,4 +1,9 @@
|
|||||||
# 更新日志
|
# 更新日志
|
||||||
|
## v4.0.3
|
||||||
|
* 功能新增:允许为角色应用绑定模型,如指定某个角色只能使用某个模型
|
||||||
|
* Bug修复:兼容 gpt-4-turbo-2024-04-09 模型的函数调用 Bug
|
||||||
|
* Bug修复:修复MidJourney在任务超时后出现后面的任务覆盖前面任务的问题
|
||||||
|
*
|
||||||
|
|
||||||
## 4.0.2
|
## 4.0.2
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ type ApiRequest struct {
|
|||||||
Stream bool `json:"stream"`
|
Stream bool `json:"stream"`
|
||||||
Messages []interface{} `json:"messages,omitempty"`
|
Messages []interface{} `json:"messages,omitempty"`
|
||||||
Prompt []interface{} `json:"prompt,omitempty"` // 兼容 ChatGLM
|
Prompt []interface{} `json:"prompt,omitempty"` // 兼容 ChatGLM
|
||||||
Tools []interface{} `json:"tools,omitempty"`
|
Tools []Tool `json:"tools,omitempty"`
|
||||||
Functions []interface{} `json:"functions,omitempty"` // 兼容中转平台
|
Functions []interface{} `json:"functions,omitempty"` // 兼容中转平台
|
||||||
|
|
||||||
ToolChoice string `json:"tool_choice,omitempty"`
|
ToolChoice string `json:"tool_choice,omitempty"`
|
||||||
|
@ -8,19 +8,14 @@ type ToolCall struct {
|
|||||||
} `json:"function"`
|
} `json:"function"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Tool struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
Function Function `json:"function"`
|
||||||
|
}
|
||||||
|
|
||||||
type Function struct {
|
type Function struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Parameters Parameters `json:"parameters"`
|
Parameters map[string]interface{} `json:"parameters"`
|
||||||
}
|
Required interface{} `json:"required,omitempty"`
|
||||||
|
|
||||||
type Parameters struct {
|
|
||||||
Type string `json:"type"`
|
|
||||||
Required []string `json:"required"`
|
|
||||||
Properties map[string]Property `json:"properties"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Property struct {
|
|
||||||
Type string `json:"type"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ func (h *ChatHandler) sendMessage(ctx context.Context, session *types.ChatSessio
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
var tools = make([]interface{}, 0)
|
var tools = make([]types.Tool, 0)
|
||||||
for _, v := range items {
|
for _, v := range items {
|
||||||
var parameters map[string]interface{}
|
var parameters map[string]interface{}
|
||||||
err = utils.JsonDecode(v.Parameters, ¶meters)
|
err = utils.JsonDecode(v.Parameters, ¶meters)
|
||||||
@ -248,15 +248,20 @@ func (h *ChatHandler) sendMessage(ctx context.Context, session *types.ChatSessio
|
|||||||
}
|
}
|
||||||
required := parameters["required"]
|
required := parameters["required"]
|
||||||
delete(parameters, "required")
|
delete(parameters, "required")
|
||||||
tools = append(tools, gin.H{
|
tool := types.Tool{
|
||||||
"type": "function",
|
Type: "function",
|
||||||
"function": gin.H{
|
Function: types.Function{
|
||||||
"name": v.Name,
|
Name: v.Name,
|
||||||
"description": v.Description,
|
Description: v.Description,
|
||||||
"parameters": parameters,
|
Parameters: parameters,
|
||||||
"required": required,
|
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
|
// Fixed: compatible for gpt4-turbo-xxx model
|
||||||
|
if !strings.HasPrefix(req.Model, "gpt-4-turbo-") {
|
||||||
|
tool.Function.Required = required
|
||||||
|
}
|
||||||
|
tools = append(tools, tool)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(tools) > 0 {
|
if len(tools) > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user