mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-10 23:59:45 +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 {
|
import {
|
||||||
|
isClaude45ReasoningModel,
|
||||||
isClaudeReasoningModel,
|
isClaudeReasoningModel,
|
||||||
isNotSupportTemperatureAndTopP,
|
isNotSupportTemperatureAndTopP,
|
||||||
isSupportedFlexServiceTier
|
isSupportedFlexServiceTier
|
||||||
@ -19,7 +20,10 @@ export function getTemperature(assistant: Assistant, model: Model): number | und
|
|||||||
if (assistant.settings?.reasoning_effort && isClaudeReasoningModel(model)) {
|
if (assistant.settings?.reasoning_effort && isClaudeReasoningModel(model)) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
if (isNotSupportTemperatureAndTopP(model)) {
|
if (
|
||||||
|
isNotSupportTemperatureAndTopP(model) ||
|
||||||
|
(isClaude45ReasoningModel(model) && assistant.settings?.enableTopP && !assistant.settings?.enableTemperature)
|
||||||
|
) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
const assistantSettings = getAssistantSettings(assistant)
|
const assistantSettings = getAssistantSettings(assistant)
|
||||||
@ -33,7 +37,10 @@ export function getTopP(assistant: Assistant, model: Model): number | undefined
|
|||||||
if (assistant.settings?.reasoning_effort && isClaudeReasoningModel(model)) {
|
if (assistant.settings?.reasoning_effort && isClaudeReasoningModel(model)) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
if (isNotSupportTemperatureAndTopP(model)) {
|
if (
|
||||||
|
isNotSupportTemperatureAndTopP(model) ||
|
||||||
|
(isClaude45ReasoningModel(model) && assistant.settings?.enableTemperature)
|
||||||
|
) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
const assistantSettings = getAssistantSettings(assistant)
|
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)
|
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 {
|
export function isClaudeReasoningModel(model?: Model): boolean {
|
||||||
if (!model) {
|
if (!model) {
|
||||||
return false
|
return false
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user