Skip to content

Commit

Permalink
feat: toolCall 默认配置化
Browse files Browse the repository at this point in the history
  • Loading branch information
bincooo committed Jun 8, 2024
1 parent 3a2e2c8 commit c25d441
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ custom-llm:
baseUrl: http://127.0.0.1:8080
useProxy: false

# toolCall 默认配置化; 在 flags 关闭时也可用
toolCall:
id: -1
enabled: false
tasks: false

# 图片放大,domain需要公网可访问的地址
# key请到https://bigjpg.com获取,每月30次免费
# 目前注册没有限制,可配置多个key轮询
Expand Down
4 changes: 3 additions & 1 deletion internal/common/gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ func GetGinToolValue(ctx *gin.Context) pkg.Keyv[interface{}] {
tool, ok := GetGinValue[pkg.Keyv[interface{}]](ctx, vars.GinTool)
if !ok {
tool = pkg.Keyv[interface{}]{
"id": "-1",
"id": "-1",
"enabled": false,
"tasks": false,
}
}
return tool
Expand Down
15 changes: 15 additions & 0 deletions internal/gin.handler/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ func completions(ctx *gin.Context) {
response.Error(ctx, -1, err)
return
}

toolCall := pkg.Config.GetStringMap("toolCall")
if enabled, ok := toolCall["enabled"]; ok && enabled.(bool) {
id := fmt.Sprintf("%v", toolCall["id"])
if id == "" {
id = "-1"
}

ctx.Set(vars.GinTool, pkg.Keyv[interface{}]{
"id": id,
"enabled": enabled,
"tasks": toolCall["tasks"].(bool),
})
}

matchers := common.XmlFlags(ctx, &completion)
ctx.Set(vars.GinCompletion, completion)

Expand Down

0 comments on commit c25d441

Please sign in to comment.