mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-30 15:59:09 +08:00
fix: update token limits for Claude-4 models and refine reasoning checks in OpenAIProvider
- Adjusted max token limit for 'claude-sonnet-4' and 'claude-opus-4' models from 64000 to 32000. - Simplified reasoning checks in OpenAIProvider to combine conditions for supported models, enhancing code clarity.
This commit is contained in:
parent
87d178773a
commit
eca3f1d71e
@ -2617,7 +2617,7 @@ export const THINKING_TOKEN_MAP: Record<string, { min: number; max: number }> =
|
|||||||
|
|
||||||
// Claude models
|
// Claude models
|
||||||
'claude-3[.-]7.*sonnet.*$': { min: 1024, max: 64000 },
|
'claude-3[.-]7.*sonnet.*$': { min: 1024, max: 64000 },
|
||||||
'claude-(:?sonnet|opus)-4.*$': { min: 1024, max: 64000 }
|
'claude-(:?sonnet|opus)-4.*$': { min: 1024, max: 32000 }
|
||||||
}
|
}
|
||||||
|
|
||||||
export const findTokenLimit = (modelId: string): { min: number; max: number } | undefined => {
|
export const findTokenLimit = (modelId: string): { min: number; max: number } | undefined => {
|
||||||
|
|||||||
@ -281,21 +281,13 @@ export default class OpenAIProvider extends BaseOpenAIProvider {
|
|||||||
|
|
||||||
// OpenRouter models
|
// OpenRouter models
|
||||||
if (model.provider === 'openrouter') {
|
if (model.provider === 'openrouter') {
|
||||||
if (isSupportedReasoningEffortModel(model)) {
|
if (isSupportedReasoningEffortModel(model) || isSupportedThinkingTokenModel(model)) {
|
||||||
return {
|
return {
|
||||||
reasoning: {
|
reasoning: {
|
||||||
effort: assistant?.settings?.reasoning_effort
|
effort: assistant?.settings?.reasoning_effort
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSupportedThinkingTokenModel(model)) {
|
|
||||||
return {
|
|
||||||
reasoning: {
|
|
||||||
max_tokens: budgetTokens
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Qwen models
|
// Qwen models
|
||||||
@ -634,7 +626,10 @@ export default class OpenAIProvider extends BaseOpenAIProvider {
|
|||||||
|
|
||||||
if (chunk.choices && chunk.choices.length > 0) {
|
if (chunk.choices && chunk.choices.length > 0) {
|
||||||
const delta = chunk.choices[0]?.delta
|
const delta = chunk.choices[0]?.delta
|
||||||
if (delta?.reasoning_content || delta?.reasoning) {
|
if (
|
||||||
|
(delta?.reasoning_content && delta?.reasoning_content !== '\n') ||
|
||||||
|
(delta?.reasoning && delta?.reasoning !== '\n')
|
||||||
|
) {
|
||||||
yield { type: 'reasoning', textDelta: delta.reasoning_content || delta.reasoning }
|
yield { type: 'reasoning', textDelta: delta.reasoning_content || delta.reasoning }
|
||||||
}
|
}
|
||||||
if (delta?.content) {
|
if (delta?.content) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user