chore: Update example to print follow up event#100
Conversation
Change-Id: I37bd0a8ccc9e74c010ee204442dfde291132e6c3
WalkthroughThe event handling logic in the chat example was refined to print message content only for follow-up messages upon conversation completion, while other messages print token usage. Executor shutdown was moved exclusively to the Changes
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
example/src/main/java/example/chat/StreamChatExample.java (1)
80-80:⚠️ Potential issuePotential redundant executor shutdown
There's now a redundant call to
shutdownExecutor()here. The executor is already shut down when the DONE event is received (line 64), which could lead to attempting to shut down an already terminated executor.Consider one of these approaches:
- Remove this line since shutdown now happens in the DONE event handler
- Add a check to only shut down if not already terminated
- Add a comment explaining this is a fallback in case no DONE event is received
- coze.shutdownExecutor(); + // Only shut down if not already terminated by DONE event + if (!coze.isExecutorTerminated()) { + coze.shutdownExecutor(); + }
🧹 Nitpick comments (1)
example/src/main/java/example/chat/StreamChatExample.java (1)
74-74: Update comment to use English instead of ChineseLine 74 contains a comment in Chinese. For consistency with the rest of the codebase, consider translating it to English.
- // 为了防止程序立即退出,添加一个简单的等待 + // Add a simple wait to prevent the program from exiting immediately
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
example/src/main/java/example/chat/StreamChatExample.java(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: test (Java 17 on Windows)
- GitHub Check: test (Java 11 on Windows)
🔇 Additional comments (2)
example/src/main/java/example/chat/StreamChatExample.java (2)
59-62: Good addition for visibility of completed messagesAdding this print statement provides better visibility into the complete message when a conversation is completed, which is helpful for debugging and monitoring purposes.
63-65: Good separation of shutdown logicMoving the executor shutdown to the DONE event handler is a proper separation of concerns. This ensures that the executor is only shut down when all processing is truly complete rather than on conversation completion.
Change-Id: Ifdbf04751c7e0eb7003e603caa274b62169cf563
Change-Id: Ib75f116ac81eae87abe95d1b39fda55cbfd837da
Change-Id: I37bd0a8ccc9e74c010ee204442dfde291132e6c3