-
Notifications
You must be signed in to change notification settings - Fork 61.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: enforce that the first message (excluding system messages) is a … #6311
Conversation
…user message in the Deepseek API
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis pull request updates the Changes
Sequence Diagram(s)sequenceDiagram
participant Client as ChatClient
participant DS as DeepSeekApi
participant Server as ChatEngine
Client->>DS: Initiate chat(messages)
DS->>DS: Create filteredMessages array
DS->>DS: Retain all system messages
DS->>DS: Add the first user message directly
DS->>DS: Conditionally add subsequent messages
DS->>Server: Send requestPayload(filteredMessages)
Server-->>Client: Return chat response
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
app/client/platforms/deepseek.ts (1)
78-78
: Translate the Chinese comment to English for codebase consistency.The comment is in Chinese while the rest of the codebase appears to be in English. For consistency and to make the code accessible to all developers, please translate the comment.
- // 检测并修复消息顺序,确保除system外的第一个消息是user + // Check and fix message order, ensure the first message (excluding system messages) is a user message
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/client/platforms/deepseek.ts
(2 hunks)
🔇 Additional comments (2)
app/client/platforms/deepseek.ts (2)
79-95
: The message filtering logic looks good.The implementation correctly ensures that:
- All system messages are retained
- The first non-system message must be a user message
- Messages after the first user message are included as expected
This aligns perfectly with the PR objective to "enforce that the first message (excluding system messages) is a user message in the Deepseek API."
Consider adding a debug log statement showing how many messages were filtered out, which could be helpful for troubleshooting:
// After filtering logic + console.log(`[Deepseek] Filtered ${messages.length - filteredMessages.length} messages to ensure proper ordering`);
107-107
: LGTM: Correctly uses the filtered messages array.The implementation properly replaces the original messages array with the filtered one in the request payload.
Your build has completed! |
…user message in the Deepseek API
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
📝 补充信息 | Additional Information
closes #6305
Summary by CodeRabbit