Skip to content

fix(chat): support DeepSeek reasoning models by preserving reasoning_content#72

Open
Frankli9986 wants to merge 9 commits into
LingyiChen-AI:mainfrom
Frankli9986:fix-53-deepseek-reasoning
Open

fix(chat): support DeepSeek reasoning models by preserving reasoning_content#72
Frankli9986 wants to merge 9 commits into
LingyiChen-AI:mainfrom
Frankli9986:fix-53-deepseek-reasoning

Conversation

@Frankli9986

Copy link
Copy Markdown

Closes #53

Problem

Users configuring DeepSeek (e.g. deepseek-reasoner / V4 thinking models) hit the API error:

The reasoning_content in the thinking mode must be passed back to the API.

This happens on the second turn of a chat session. The current code routes DeepSeek through the generic @ai-sdk/openai provider, which does not recognize DeepSeek's reasoning_content. As a result:

  1. The first response's reasoning_content is dropped.
  2. On the next request convertToModelMessages() produces an assistant message without reasoning_content.
  3. DeepSeek API rejects the request.

Changes

Dependencies

  • Add @ai-sdk/deepseek for first-class DeepSeek API support.

Settings / provider selection

  • Add deepseek as a first-class AI provider in settings-store.ts and settings-dialog.tsx.
  • Default config: https://api.deepseek.com + deepseek-chat.

Model list endpoint

  • src/app/api/ai/models/route.ts: add DeepSeek /models lookup.

Provider factory

  • src/lib/ai/provider.ts: route deepseek provider to createDeepSeek().

Chat streaming

  • src/app/api/ai/chat/route.ts:
    • Enable sendReasoning: true so reasoning tokens flow to the client as UI message parts.
    • Persist reasoning in chatMessages.metadata for 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

  1. Settings → AI Provider → select DeepSeek
  2. Enter API key and model (e.g. deepseek-reasoner or deepseek-chat)
  3. Start a chat, ask AI to fill resume
  4. Continue the conversation — no reasoning_content error on subsequent turns

Scope note

This is intentionally focused on the chat route because issue #53 is a chat/session error. The other generateText call sites (tools.ts for analyzeJdMatch and translateResume) do not maintain multi-turn context, so they are not affected by the reasoning_content requirement.

@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

报错:The reasoning_content in the thinking mode must be passed back to the API.

1 participant