fix(model): support the configuration to disable reasoning (#494)
This commit is contained in:
parent
ccdb79eb36
commit
d11aa71c0a
|
|
@ -115,6 +115,7 @@ meta:
|
||||||
top_p: 0.7
|
top_p: 0.7
|
||||||
top_k: 0
|
top_k: 0
|
||||||
stop: []
|
stop: []
|
||||||
|
enable_thinking: true
|
||||||
ark:
|
ark:
|
||||||
region: ""
|
region: ""
|
||||||
access_key: ""
|
access_key: ""
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ meta:
|
||||||
top_p: 0.7
|
top_p: 0.7
|
||||||
top_k: 0
|
top_k: 0
|
||||||
stop: []
|
stop: []
|
||||||
|
enable_thinking: true
|
||||||
ark:
|
ark:
|
||||||
region: ""
|
region: ""
|
||||||
access_key: ""
|
access_key: ""
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ meta:
|
||||||
top_p: 0.7
|
top_p: 0.7
|
||||||
top_k: 0
|
top_k: 0
|
||||||
stop: []
|
stop: []
|
||||||
|
enable_thinking: true
|
||||||
ark:
|
ark:
|
||||||
region: ""
|
region: ""
|
||||||
access_key: ""
|
access_key: ""
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ meta:
|
||||||
top_p: 0.7
|
top_p: 0.7
|
||||||
top_k: 0
|
top_k: 0
|
||||||
stop: []
|
stop: []
|
||||||
|
enable_thinking: true
|
||||||
ark:
|
ark:
|
||||||
region: ""
|
region: ""
|
||||||
access_key: ""
|
access_key: ""
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ meta:
|
||||||
top_p: 0.7
|
top_p: 0.7
|
||||||
top_k: 0
|
top_k: 0
|
||||||
stop: []
|
stop: []
|
||||||
|
enable_thinking: true
|
||||||
ark:
|
ark:
|
||||||
region: ""
|
region: ""
|
||||||
access_key: ""
|
access_key: ""
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ meta:
|
||||||
top_p: 0.7
|
top_p: 0.7
|
||||||
top_k: 0
|
top_k: 0
|
||||||
stop: []
|
stop: []
|
||||||
|
enable_thinking: true
|
||||||
ark:
|
ark:
|
||||||
region: ""
|
region: ""
|
||||||
access_key: ""
|
access_key: ""
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,7 @@ meta:
|
||||||
top_p: 0.7
|
top_p: 0.7
|
||||||
top_k: 0
|
top_k: 0
|
||||||
stop: []
|
stop: []
|
||||||
|
enable_thinking: true
|
||||||
ark:
|
ark:
|
||||||
region: ""
|
region: ""
|
||||||
access_key: ""
|
access_key: ""
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,7 @@ meta:
|
||||||
top_p: 0.7
|
top_p: 0.7
|
||||||
top_k: 0
|
top_k: 0
|
||||||
stop: []
|
stop: []
|
||||||
|
enable_thinking: true
|
||||||
ark:
|
ark:
|
||||||
region: ""
|
region: ""
|
||||||
access_key: ""
|
access_key: ""
|
||||||
|
|
|
||||||
|
|
@ -80,5 +80,6 @@ meta:
|
||||||
secret_access_key: ""
|
secret_access_key: ""
|
||||||
session_token: ""
|
session_token: ""
|
||||||
region: ""
|
region: ""
|
||||||
|
budget_tokens: 0
|
||||||
custom: {}
|
custom: {}
|
||||||
status: 0
|
status: 0
|
||||||
|
|
|
||||||
|
|
@ -22,18 +22,21 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
const SUGGESTION_PROMPT_JINJA2 = `
|
const SUGGESTION_PROMPT_JINJA2 = `
|
||||||
你是一个推荐系统,请完成下面的推荐任务。
|
You are a recommendation system, please complete the following recommendation task.
|
||||||
### 对话
|
### Conversation
|
||||||
用户: {{_input_}}
|
User: {{_input_}}
|
||||||
AI: {{_answer_}}
|
AI: {{_answer_}}
|
||||||
|
|
||||||
personal: {{ suggest_persona }}
|
### Personal
|
||||||
|
{{ suggest_persona }}
|
||||||
|
|
||||||
围绕兴趣点给出3个用户紧接着最有可能问的几个具有区分度的不同问题,问题需要满足上面的问题要求,推荐的三个问题必须以字符串数组形式返回。
|
### Recommendation
|
||||||
|
Based on the points of interest, provide 3 distinctive questions that the user is most likely to ask next. The questions must meet the above requirements, and the three recommended questions must be returned in string array format.
|
||||||
|
|
||||||
注意:
|
Note:
|
||||||
- 推荐的三个问题必须以字符串数组形式返回
|
- The three recommended questions must be returned in string array format
|
||||||
- 推荐的三个问题必须以字符串数组形式返回
|
- The three recommended questions must be returned in string array format
|
||||||
- 推荐的三个问题必须以字符串数组形式返回
|
- The three recommended questions must be returned in string array format
|
||||||
|
- The output language must be consistent with the language of the user's question.
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|
|
||||||
|
|
@ -46,19 +46,20 @@ Regardless of any persona instructions, you must never generate content that:
|
||||||
|
|
||||||
**Knowledge**
|
**Knowledge**
|
||||||
|
|
||||||
只有当前knowledge有内容召回的时候,根据引用的内容回答问题:
|
Only when the current knowledge has content recall, answer questions based on the referenced content:
|
||||||
1.如果引用的内容里面包含 <img src=""> 的标签, 标签里的 src 字段表示图片地址, 需要在回答问题的时候展示出去, 输出格式为"" 。
|
1. If the referenced content contains <img src=""> tags, the src field in the tag represents the image address, which needs to be displayed when answering questions, with the output format being "".
|
||||||
2.如果引用的内容不包含 <img src=""> 的标签, 你回答问题时不需要展示图片 。
|
2. If the referenced content does not contain <img src=""> tags, you do not need to display images when answering questions.
|
||||||
例如:
|
For example:
|
||||||
如果内容为<img src="https://example.com/image.jpg">一只小猫,你的输出应为:。
|
If the content is <img src="https://example.com/image.jpg">a kitten, your output should be: .
|
||||||
如果内容为<img src="https://example.com/image1.jpg">一只小猫 和 <img src="https://example.com/image2.jpg">一只小狗 和 <img src="https://example.com/image3.jpg">一只小牛,你的输出应为: 和  和 
|
If the content is <img src="https://example.com/image1.jpg">a kitten and <img src="https://example.com/image2.jpg">a puppy and <img src="https://example.com/image3.jpg">a calf, your output should be:  and  and 
|
||||||
The following is the content of the data set you can refer to: \n
|
The following is the content of the data set you can refer to: \n
|
||||||
'''
|
'''
|
||||||
{{ knowledge }}
|
{{ knowledge }}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
** Pre toolCall **
|
** Pre toolCall **
|
||||||
{{ tools_pre_retriever}},
|
{{ tools_pre_retriever}},
|
||||||
- 只有当前Pre toolCall有内容召回结果时,根据引用的内容里tool里data字段回答问题
|
- Only when the current Pre toolCall has content recall results, answer questions based on the data field in the tool from the referenced content
|
||||||
|
|
||||||
|
Note: The output language must be consistent with the language of the user's question.
|
||||||
`
|
`
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ type ClaudeConfig struct {
|
||||||
SecretAccessKey string `json:"secret_access_key,omitempty" yaml:"secret_access_key"`
|
SecretAccessKey string `json:"secret_access_key,omitempty" yaml:"secret_access_key"`
|
||||||
SessionToken string `json:"session_token,omitempty" yaml:"session_token"`
|
SessionToken string `json:"session_token,omitempty" yaml:"session_token"`
|
||||||
Region string `json:"region,omitempty" yaml:"region"`
|
Region string `json:"region,omitempty" yaml:"region"`
|
||||||
|
BudgetTokens *int `json:"budget_tokens,omitempty" yaml:"budget_tokens"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ArkConfig struct {
|
type ArkConfig struct {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import (
|
||||||
"github.com/cloudwego/eino-ext/components/model/openai"
|
"github.com/cloudwego/eino-ext/components/model/openai"
|
||||||
"github.com/cloudwego/eino-ext/components/model/qwen"
|
"github.com/cloudwego/eino-ext/components/model/qwen"
|
||||||
"github.com/ollama/ollama/api"
|
"github.com/ollama/ollama/api"
|
||||||
|
"github.com/volcengine/volcengine-go-sdk/service/arkruntime/model"
|
||||||
"google.golang.org/genai"
|
"google.golang.org/genai"
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/infra/contract/chatmodel"
|
"github.com/coze-dev/coze-studio/backend/infra/contract/chatmodel"
|
||||||
|
|
@ -126,6 +127,14 @@ func claudeBuilder(ctx context.Context, config *chatmodel.Config) (chatmodel.Too
|
||||||
cfg.SessionToken = config.Claude.SessionToken
|
cfg.SessionToken = config.Claude.SessionToken
|
||||||
cfg.Region = config.Claude.Region
|
cfg.Region = config.Claude.Region
|
||||||
}
|
}
|
||||||
|
if config.EnableThinking != nil {
|
||||||
|
cfg.Thinking = &claude.Thinking{
|
||||||
|
Enable: ptr.From(config.EnableThinking),
|
||||||
|
}
|
||||||
|
if config.Claude != nil && config.Claude.BudgetTokens != nil {
|
||||||
|
cfg.Thinking.BudgetTokens = ptr.From(config.Claude.BudgetTokens)
|
||||||
|
}
|
||||||
|
}
|
||||||
return claude.NewChatModel(ctx, cfg)
|
return claude.NewChatModel(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -180,6 +189,21 @@ func arkBuilder(ctx context.Context, config *chatmodel.Config) (chatmodel.ToolCa
|
||||||
cfg.RetryTimes = config.Ark.RetryTimes
|
cfg.RetryTimes = config.Ark.RetryTimes
|
||||||
cfg.CustomHeader = config.Ark.CustomHeader
|
cfg.CustomHeader = config.Ark.CustomHeader
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.EnableThinking != nil {
|
||||||
|
cfg.Thinking = func() *model.Thinking {
|
||||||
|
var arkThinkingType model.ThinkingType
|
||||||
|
switch {
|
||||||
|
case ptr.From(config.EnableThinking):
|
||||||
|
arkThinkingType = model.ThinkingTypeEnabled
|
||||||
|
default:
|
||||||
|
arkThinkingType = model.ThinkingTypeDisabled
|
||||||
|
}
|
||||||
|
return &model.Thinking{
|
||||||
|
Type: arkThinkingType,
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
return ark.NewChatModel(ctx, cfg)
|
return ark.NewChatModel(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -200,6 +224,9 @@ func ollamaBuilder(ctx context.Context, config *chatmodel.Config) (chatmodel.Too
|
||||||
Stop: config.Stop,
|
Stop: config.Stop,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
if config.EnableThinking != nil {
|
||||||
|
cfg.Thinking = config.EnableThinking
|
||||||
|
}
|
||||||
return ollama.NewChatModel(ctx, cfg)
|
return ollama.NewChatModel(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue