mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-05 00:45:29 +08:00
22 lines
750 B
Go
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
|
|
}
|