-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 QianWen Bot #892
Fix QianWen Bot #892
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@coderabbitai review |
Actions performedReview triggered.
|
WalkthroughThe Changes
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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: 3
Outside diff range and nitpick comments (2)
src/bots/QianWenBot.js (2)
85-86
: Remove commented-out code for cleanlinessThe fields
timeout
andopenSearch
are commented out. If they are no longer needed, consider removing them to maintain code cleanliness and reduce clutter.Apply this diff to remove the unnecessary comments:
- // timeout: 17, - // openSearch: false,
133-147
: Use strict equality checksWhen comparing string values, it is best practice to use strict equality operators (
===
) to avoid type coercion issues. This ensures that the comparison behaves as expected.Apply this diff to update the equality checks:
- if (contentItem.contentType == "plugin") { + if (contentItem.contentType === "plugin") { ... - } else if (contentItem.contentType == "text") { + } else if (contentItem.contentType === "text") { ... - } else if (contentItem.contentType == "referenceLink") { + } else if (contentItem.contentType === "referenceLink") {
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/bots/QianWenBot.js (3 hunks)
Additional comments not posted (1)
src/bots/QianWenBot.js (1)
102-104
: Verify the updated SSE endpoint URLThe SSE endpoint URL has been updated to
https://qianwen.biz.aliyun.com/dialog/conversation
. Ensure that this new URL is correct and that the server is properly configured to handle requests at this endpoint.Run the following script to verify the accessibility of the new endpoint:
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.
@cesaryuan please take a look at the review, thanks.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
I have adapted the code generated by AI and fixed the bug and format problem imported by it. |
@coderabbitai review |
✅ Actions performedReview triggered.
|
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: 1
🧹 Outside diff range and nitpick comments (3)
src/bots/QianWenBot.js (3)
78-87
: LGTM! Consider using object shorthand notation for improved readability.The changes to the payload structure look good and align with the updated API requirements. The addition of
mode
,requestId
, andsessionType
fields, along with the modification ofparentMsgId
, enhances the flexibility and uniqueness of each request.Consider using object shorthand notation for
sessionId
andmode
to improve code consistency:- sessionId: context.sessionId, - mode: "chat", + sessionId: context.sessionId, + mode,
100-107
: LGTM! Consider extracting the SSE URL to a constant for improved maintainability.The update to the SSE URL and the addition of
withCredentials: true
are appropriate changes that align with the new API requirements and ensure proper authentication.For improved maintainability, consider extracting the SSE URL to a constant at the top of the file:
+ const SSE_URL = "https://qianwen.biz.aliyun.com/dialog/conversation"; // ... (later in the code) const source = new SSE( - "https://qianwen.biz.aliyun.com/dialog/conversation", + SSE_URL, { headers, payload, withCredentials: true, }, );
125-165
: LGTM! Excellent refactoring of content processing logic.The changes significantly improve the readability, maintainability, and efficiency of the content processing logic. The switch statement provides a clear structure for handling different content types, and the use of an array to build the content is more efficient than string concatenation.
Consider using a template literal for the "referenceLink" case to improve readability:
contentPieces.push( - `> 相关链接 · ${links.length}\n` + - links - .map((link) => `> - [${link.title}](${link.url})`) - .join("\n") + - "\n", + `> 相关链接 · ${links.length}\n${links + .map((link) => `> - [${link.title}](${link.url})`) + .join("\n")}\n` );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- src/bots/QianWenBot.js (3 hunks)
🔇 Additional comments (1)
src/bots/QianWenBot.js (1)
113-116
: LGTM! Improved handling of empty messages.The addition of this check enhances the robustness of the message handling process. It effectively prevents unnecessary processing of whitespace-only chunks, which could occur as the last message in the stream.
Hi @cesaryuan, Since the PR was submitted a while ago, I'd like to check with you if the changes are still valid and functioning properly. Thank you! |
Just tested locally, it works fine. Here is the screenshot: |
close: #864 #846 part of #874
Summary by CodeRabbit
New Features
mode
field for chat sessions and a newrequestId
for better tracking.Bug Fixes
Chores