-
Notifications
You must be signed in to change notification settings - Fork 0
Streaming Support [Chat Embed] [Client Component] #8
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
base: main
Are you sure you want to change the base?
Conversation
Greptile SummaryThis PR adds support for real-time token streaming in the chat widget by introducing a new Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant ChatWidget
participant useChat Hook
participant API Client
participant Server
participant State Manager
User->>ChatWidget: Send message
ChatWidget->>useChat Hook: sendMessage(content)
useChat Hook->>State Manager: Create user message
useChat Hook->>State Manager: Create empty assistant message
useChat Hook->>API Client: sendMessage({embedId, message, sessionId})
API Client->>Server: POST /chat/message (SSE stream)
Server-->>API Client: Stream response start
API Client->>useChat Hook: ReadableStream<Uint8Array>
loop Process SSE Events
Server-->>API Client: data: {type: 'chunk', content: 'token'}
API Client->>useChat Hook: parseSSEEvent
useChat Hook->>State Manager: Append chunk to message.content
State Manager-->>ChatWidget: Update messages (streaming)
ChatWidget-->>User: Display partial response
end
Server-->>API Client: data: {type: 'done'}
useChat Hook->>State Manager: Mark message status: 'sent'
State Manager-->>ChatWidget: Update message status
ChatWidget-->>User: Show complete response
|
Note
Enable token-by-token streaming for assistant replies
chunkevent handling inuseChatto append content incrementally and keep statusstreamingmessageas legacy full response; retains support but prioritizeschunkSSEEventTypeintypesto includechunkand annotatesmessageas legacyChatWidget.tsx(usesDEFAULT_ENGINE_URLfrom API client)Written by Cursor Bugbot for commit e54bf51. This will update automatically on new commits. Configure here.