fix(chat): support DeepSeek reasoning models by preserving reasoning_content#72
Open
Frankli9986 wants to merge 9 commits into
Open
fix(chat): support DeepSeek reasoning models by preserving reasoning_content#72Frankli9986 wants to merge 9 commits into
Frankli9986 wants to merge 9 commits into
Conversation
|
@Frankli9986 is attempting to deploy a commit to the twwch's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #53
Problem
Users configuring DeepSeek (e.g.
deepseek-reasoner/ V4 thinking models) hit the API error:This happens on the second turn of a chat session. The current code routes DeepSeek through the generic
@ai-sdk/openaiprovider, which does not recognize DeepSeek'sreasoning_content. As a result:reasoning_contentis dropped.convertToModelMessages()produces an assistant message withoutreasoning_content.Changes
Dependencies
@ai-sdk/deepseekfor first-class DeepSeek API support.Settings / provider selection
deepseekas a first-class AI provider insettings-store.tsandsettings-dialog.tsx.https://api.deepseek.com+deepseek-chat.Model list endpoint
src/app/api/ai/models/route.ts: add DeepSeek/modelslookup.Provider factory
src/lib/ai/provider.ts: routedeepseekprovider tocreateDeepSeek().Chat streaming
src/app/api/ai/chat/route.ts:sendReasoning: trueso reasoning tokens flow to the client as UI message parts.reasoninginchatMessages.metadatafor historical message round-trips.Message conversion
src/lib/ai/utils.ts: restore{ type: 'reasoning' }parts from DB metadata.Tests
src/lib/ai/provider.test.ts: verify DeepSeek model creation.src/lib/ai/utils.test.ts: verify reasoning part round-trip.Verification
deepseek-reasonerordeepseek-chat)reasoning_contenterror on subsequent turnsScope note
This is intentionally focused on the chat route because issue #53 is a chat/session error. The other
generateTextcall sites (tools.tsforanalyzeJdMatchandtranslateResume) do not maintain multi-turn context, so they are not affected by thereasoning_contentrequirement.