Skip to content

Commit 49b4546

Browse files
committed
manually remove reasoning tokens if exclude=true
1 parent a4d0ff5 commit 49b4546

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

backend/src/llm-apis/openrouter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export function openRouterLanguageModel(model: Model) {
3737
extraBody,
3838
}).languageModel(model, {
3939
usage: { include: true },
40-
includeReasoning: true,
4140
logprobs: true,
4241
})
4342
}

backend/src/llm-apis/vercel-ai-sdk/ai-sdk.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ import type {
2929
OpenAIModel,
3030
} from '@codebuff/common/constants'
3131
import type { CodebuffMessage, Message } from '@codebuff/common/types/message'
32-
import type { OpenRouterUsageAccounting } from '@openrouter/ai-sdk-provider'
32+
import type {
33+
OpenRouterProviderOptions,
34+
OpenRouterUsageAccounting,
35+
} from '@openrouter/ai-sdk-provider'
3336
import type { AssistantModelMessage, UserModelMessage, LanguageModel } from 'ai'
3437
import type { z } from 'zod/v4'
3538

@@ -128,6 +131,15 @@ export const promptAiSdkStream = async function* (
128131
})
129132
}
130133
if (chunk.type === 'reasoning-delta') {
134+
if (
135+
(
136+
options.providerOptions?.openrouter as
137+
| OpenRouterProviderOptions
138+
| undefined
139+
)?.reasoning?.exclude
140+
) {
141+
continue
142+
}
131143
if (!reasoning) {
132144
reasoning = true
133145
yield `${startToolTag}{

0 commit comments

Comments
 (0)