Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does
点击生成后
这个PR的主要作用是向用户清晰展示,某个请求被“截断”的原因,方便排查是服务端还是客户端的问题
推理模型的继续生成效果不太好
Before this PR:
After this PR:
Why we need it and why it was done in this way
This feature is needed to properly handle streaming responses from AI providers that may finish for various reasons (length, content filtering, stop sequences, etc.). Without proper finish reason handling, users may not understand why their AI responses ended unexpectedly.
The implementation was done in the
AiSdkToChunkAdapterbecause it is the central component responsible for converting AI SDK streams into Cherry Studio's internal chunk format. This ensures consistent behavior across all AI providers that use the AI SDK integration.The following tradeoffs were made:
The following alternatives were considered:
Links to places where the discussion took place:
Breaking changes
This PR does not introduce breaking changes. All existing functionality remains intact, with only additions to the streaming response handling.
Special notes for your reviewer
The main changes are in:
src/renderer/src/aiCore/chunk/AiSdkToChunkAdapter.ts: Core logic for finish reason handlingPlease pay special attention to the simplified warning condition that only triggers when there is text content but no finish reason.
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
Release note