Skip to content

Commit 608c8e2

Browse files
hiSandog陈家名
andauthored
fix: make reasoning.exclude option actually suppress reasoning tokens (#495)
Co-authored-by: 陈家名 <chenjiaming@kezaihui.com>
1 parent b6cc513 commit 608c8e2

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

sdk/src/impl/llm.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -711,21 +711,20 @@ export async function* promptAiSdkStream(
711711
throw chunkValue.error
712712
}
713713
if (chunkValue.type === 'reasoning-delta') {
714-
for (const provider of ['openrouter', 'codebuff'] as const) {
715-
if (
714+
const reasoningExcluded = (['openrouter', 'codebuff'] as const).some(
715+
(p) =>
716716
(
717-
params.providerOptions?.[provider] as
717+
params.providerOptions?.[p] as
718718
| OpenRouterProviderOptions
719719
| undefined
720-
)?.reasoning?.exclude
721-
) {
722-
continue
720+
)?.reasoning?.exclude,
721+
)
722+
if (!reasoningExcluded) {
723+
yield {
724+
type: 'reasoning',
725+
text: chunkValue.text,
723726
}
724727
}
725-
yield {
726-
type: 'reasoning',
727-
text: chunkValue.text,
728-
}
729728
}
730729
if (chunkValue.type === 'text-delta') {
731730
if (!params.stopSequences) {

0 commit comments

Comments
 (0)