Files
ds2api/internal/httpapi/openai/shared/thinking_injection.go
2026-04-26 14:21:15 +08:00

22 lines
750 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.AppendThinkingInjectionPromptToLatestUser(stdReq.Messages, store.ThinkingInjectionPrompt())
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
}