mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-27 12:51:26 +08:00
feat: add isClaude45ReasoningModel function and update getTopP logic (#10988)
* feat: add isClaude45ReasoningModel function and update getTopP logic
* fix: update getTopP logic to correctly handle Claude45 model support
* fix: update getTemperature and getTopP logic to handle Claude45 model conditions
* fix: update getTemperature logic to correctly handle Claude45 model conditions
fix: refine isClaude45ReasoningModel regex pattern for better matching
(cherry picked from commit 250f59234b)
This commit is contained in:
parent
c2a78b4129
commit
cd26190fe9
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
isClaude45ReasoningModel,
|
||||
isClaudeReasoningModel,
|
||||
isNotSupportTemperatureAndTopP,
|
||||
isSupportedFlexServiceTier
|
||||
@ -19,7 +20,10 @@ export function getTemperature(assistant: Assistant, model: Model): number | und
|
||||
if (assistant.settings?.reasoning_effort && isClaudeReasoningModel(model)) {
|
||||
return undefined
|
||||
}
|
||||
if (isNotSupportTemperatureAndTopP(model)) {
|
||||
if (
|
||||
isNotSupportTemperatureAndTopP(model) ||
|
||||
(isClaude45ReasoningModel(model) && assistant.settings?.enableTopP && !assistant.settings?.enableTemperature)
|
||||
) {
|
||||
return undefined
|
||||
}
|
||||
const assistantSettings = getAssistantSettings(assistant)
|
||||
@ -33,7 +37,10 @@ export function getTopP(assistant: Assistant, model: Model): number | undefined
|
||||
if (assistant.settings?.reasoning_effort && isClaudeReasoningModel(model)) {
|
||||
return undefined
|
||||
}
|
||||
if (isNotSupportTemperatureAndTopP(model)) {
|
||||
if (
|
||||
isNotSupportTemperatureAndTopP(model) ||
|
||||
(isClaude45ReasoningModel(model) && assistant.settings?.enableTemperature)
|
||||
) {
|
||||
return undefined
|
||||
}
|
||||
const assistantSettings = getAssistantSettings(assistant)
|
||||
|
||||
@ -342,6 +342,12 @@ export function isSupportedThinkingTokenDoubaoModel(model?: Model): boolean {
|
||||
return DOUBAO_THINKING_MODEL_REGEX.test(modelId) || DOUBAO_THINKING_MODEL_REGEX.test(model.name)
|
||||
}
|
||||
|
||||
export function isClaude45ReasoningModel(model: Model): boolean {
|
||||
const modelId = getLowerBaseModelName(model.id, '/')
|
||||
const regex = /claude-(sonnet|opus|haiku)-4(-|.)5(?:-[\w-]+)?$/i
|
||||
return regex.test(modelId)
|
||||
}
|
||||
|
||||
export function isClaudeReasoningModel(model?: Model): boolean {
|
||||
if (!model) {
|
||||
return false
|
||||
|
||||
Loading…
Reference in New Issue
Block a user