mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-17 14:45:11 +08:00
新增 promptcompat 和 OpenAI shared 层的 thinking 注入逻辑, 完善配置系统的编解码与校验,更新设置管理 API 与前端 UI。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
22 lines
711 B
Go
22 lines
711 B
Go
package shared
|
|
|
|
import "ds2api/internal/promptcompat"
|
|
|
|
func ApplyThinkingInjection(store ConfigReader, stdReq promptcompat.StandardRequest) promptcompat.StandardRequest {
|
|
if store == nil || !store.ThinkingInjectionEnabled() || !stdReq.Thinking {
|
|
return stdReq
|
|
}
|
|
messages, changed := promptcompat.AppendThinkingInjectionToLatestUser(stdReq.Messages)
|
|
if !changed {
|
|
return stdReq
|
|
}
|
|
finalPrompt, toolNames := promptcompat.BuildOpenAIPrompt(messages, stdReq.ToolsRaw, "", stdReq.ToolChoice, stdReq.Thinking)
|
|
if len(toolNames) == 0 && len(stdReq.ToolNames) > 0 {
|
|
toolNames = stdReq.ToolNames
|
|
}
|
|
stdReq.Messages = messages
|
|
stdReq.FinalPrompt = finalPrompt
|
|
stdReq.ToolNames = toolNames
|
|
return stdReq
|
|
}
|