mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-17 13:13:35 +08:00
修复服务商带有[1m],运行时不带[1m]导致thinking和effort不生效问题
修复服务商带有[1m],运行时不带[1m]导致thinking和effort不生效问题
This commit is contained in:
parent
eddaec547e
commit
4056911367
@ -23,6 +23,17 @@ const TIERS = [
|
||||
},
|
||||
] as const
|
||||
|
||||
/**
|
||||
* Strip [1m]/[2m] context-window suffixes so capability overrides match
|
||||
* regardless of whether the runtime model name includes the suffix.
|
||||
* The suffix is a client-side marker (never sent to the API) but the
|
||||
* pinned env var may carry it, while the runtime model passed to
|
||||
* modelSupportsThinking/modelSupportsEffort may not.
|
||||
*/
|
||||
function stripContextSuffix(model: string): string {
|
||||
return model.replace(/\[(1|2)m\]/gi, '')
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a 3p model capability override is set for a model that matches one of
|
||||
* the pinned ANTHROPIC_DEFAULT_*_MODEL env vars.
|
||||
@ -32,12 +43,12 @@ export const get3PModelCapabilityOverride = memoize(
|
||||
if (getAPIProvider() === 'firstParty' && isFirstPartyAnthropicBaseUrl()) {
|
||||
return undefined
|
||||
}
|
||||
const m = model.toLowerCase()
|
||||
const m = stripContextSuffix(model.toLowerCase())
|
||||
for (const tier of TIERS) {
|
||||
const pinned = process.env[tier.modelEnvVar]
|
||||
const capabilities = process.env[tier.capabilitiesEnvVar]
|
||||
if (!pinned || capabilities === undefined) continue
|
||||
if (m !== pinned.toLowerCase()) continue
|
||||
if (m !== stripContextSuffix(pinned.toLowerCase())) continue
|
||||
return capabilities
|
||||
.toLowerCase()
|
||||
.split(',')
|
||||
@ -46,5 +57,5 @@ export const get3PModelCapabilityOverride = memoize(
|
||||
}
|
||||
return undefined
|
||||
},
|
||||
(model, capability) => `${model.toLowerCase()}:${capability}`,
|
||||
(model, capability) => `${stripContextSuffix(model.toLowerCase())}:${capability}`,
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user