-
Notifications
You must be signed in to change notification settings - Fork 152
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
feat: display chat events #52
Conversation
🦋 Changeset detectedLatest commit: eb9a36c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThe recent updates enhance streaming functionalities across multiple platforms, integrating event handling and content generation. FastAPI and Express backends now support more dynamic streaming responses, while Next.js frontends improve user interaction with collapsible UI components for chat events. Additionally, dependencies have been updated to support these new features. Changes
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (16)
Files skipped from review as they are similar to previous changes (14)
Additional Context UsedRuff (1)
Additional comments not posted (9)
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 as PR comments)
Additionally, you can add CodeRabbit Configration 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: 1
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: 2
templates/types/streaming/express/src/controllers/chat.controller.ts
Outdated
Show resolved
Hide resolved
templates/types/streaming/nextjs/app/components/ui/chat/chat-message.tsx
Outdated
Show resolved
Hide resolved
939d113
to
c194d7b
Compare
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
Actionable comments outside the diff hunks (1)
templates/types/streaming/fastapi/app/api/routers/chat.py (1)
Line range hint
6-6
: Remove the unused importStreamingAgentChatResponse
to clean up the code.
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
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
1d74be7
to
16a61cc
Compare
16a61cc
to
41d6a66
Compare
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
Out of diff range and nitpick comments (1)
templates/types/streaming/fastapi/app/api/routers/chat.py (1)
Line range hint
6-6
: Remove unused importStreamingAgentChatResponse
to clean up the code.- from llama_index.core.chat_engine.types import StreamingAgentChatResponse
41d6a66
to
eb9a36c
Compare
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
Out of diff range and nitpick comments (1)
templates/types/streaming/fastapi/app/api/routers/chat.py (1)
Line range hint
6-6
: Remove unused importStreamingAgentChatResponse
to clean up the code.- from llama_index.core.chat_engine.types import StreamingAgentChatResponse
@@ -25,7 +26,7 @@ const convertMessageContent = ( | |||
|
|||
export const chat = async (req: Request, res: Response) => { | |||
try { | |||
const { messages, data }: { messages: ChatMessage[]; data: any } = req.body; | |||
const { messages, data }: { messages: Message[]; data: any } = req.body; |
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.
The validation logic for messages
and userMessage
should be adjusted to check the array before popping an element to prevent runtime errors.
- const userMessage = messages.pop();
- if (!messages || !userMessage || userMessage.role !== "user") {
+ if (!messages || messages.length === 0) return res.status(400).json({ error: "No messages provided in the request." });
+ const userMessage = messages.pop();
+ if (!userMessage || userMessage.role !== "user") {
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const { messages, data }: { messages: Message[]; data: any } = req.body; | |
const { messages, data }: { messages: Message[]; data: any } = req.body; | |
if (!messages || messages.length === 0) return res.status(400).json({ error: "No messages provided in the request." }); | |
const userMessage = messages.pop(); | |
if (!userMessage || userMessage.role !== "user") { |
Summary by CodeRabbit
New Features
Enhancements
Dependencies
aiostream
and@radix-ui/react-collapsible
to manage asynchronous streams and UI collapsibility, respectively.