Files
ds2api/internal/httpapi/openai/shared/thinking_injection.go
CJACK c09a4b51a5 feat: 新增 thinking 注入配置支持,扩展设置管理与前端交互
新增 promptcompat 和 OpenAI shared 层的 thinking 注入逻辑,
完善配置系统的编解码与校验,更新设置管理 API 与前端 UI。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 13:35:20 +08:00

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
}