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:
suyao 2025-05-28 01:28:47 +08:00 committed by 亢奋猫
parent 6dba08754f
commit 173e64799e
2 changed files with 6 additions and 11 deletions

View File

@ -2617,7 +2617,7 @@ export const THINKING_TOKEN_MAP: Record<string, { min: number; max: number }> =
// Claude models
'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 => {

View File

@ -281,21 +281,13 @@ export default class OpenAIProvider extends BaseOpenAIProvider {
// OpenRouter models
if (model.provider === 'openrouter') {
if (isSupportedReasoningEffortModel(model)) {
if (isSupportedReasoningEffortModel(model) || isSupportedThinkingTokenModel(model)) {
return {
reasoning: {
effort: assistant?.settings?.reasoning_effort
}
}
}
if (isSupportedThinkingTokenModel(model)) {
return {
reasoning: {
max_tokens: budgetTokens
}
}
}
}
// Qwen models
@ -634,7 +626,10 @@ export default class OpenAIProvider extends BaseOpenAIProvider {
if (chunk.choices && chunk.choices.length > 0) {
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 }
}
if (delta?.content) {