mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-10-17 13:08:57 +08:00
Use Home credential options as authoritative model capability configuration for compat handling and prompt cache behavior. Expose quota provider operations through the public plugin host API.
33 lines
1.5 KiB
Go
33 lines
1.5 KiB
Go
package helps
|
|
|
|
import (
|
|
"github.com/router-for-me/CLIProxyAPI/v8/internal/thinking"
|
|
cliproxyauth "github.com/router-for-me/CLIProxyAPI/v8/sdk/cliproxy/auth"
|
|
cliproxyexecutor "github.com/router-for-me/CLIProxyAPI/v8/sdk/cliproxy/executor"
|
|
)
|
|
|
|
// APIKeyModelIsCompat reports whether the selected API-key model enables
|
|
// compatibility handling for Claude thinking blocks.
|
|
func APIKeyModelIsCompat(req cliproxyexecutor.Request) bool {
|
|
modelInfo, ok := cliproxyauth.ResolvedModelInfo(req)
|
|
return ok && modelInfo != nil && modelInfo.IsCompat
|
|
}
|
|
|
|
// ApplyRequestThinking preserves the registry lookup path unless the auth
|
|
// manager bound authoritative model capabilities to this execution attempt.
|
|
func ApplyRequestThinking(body []byte, req cliproxyexecutor.Request, opts cliproxyexecutor.Options, fromFormat, toFormat, provider string, normalizedUpdatesChanged ...bool) ([]byte, error) {
|
|
originalSource := opts.OriginalRequest
|
|
if len(originalSource) == 0 {
|
|
originalSource = req.Payload
|
|
}
|
|
source := req.Payload
|
|
if len(source) == 0 {
|
|
source = opts.OriginalRequest
|
|
}
|
|
summaryConfig := translatedRequestSummaryConfig(body, req.Payload, originalSource, req.Model, fromFormat, toFormat)
|
|
if modelInfo, ok := cliproxyauth.ResolvedModelInfo(req); ok {
|
|
return thinking.ApplyThinkingWithModelInfoAndSummary(body, source, req.Model, fromFormat, toFormat, provider, modelInfo, summaryConfig, normalizedUpdatesChanged...)
|
|
}
|
|
return thinking.ApplyThinkingWithSourceAndSummary(body, source, req.Model, fromFormat, toFormat, provider, summaryConfig, normalizedUpdatesChanged...)
|
|
}
|