-
Notifications
You must be signed in to change notification settings - Fork 114
feat(lightspeed): notebook chat #2754
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
Merged
karthikjeeyar
merged 16 commits into
redhat-developer:main
from
its-mitesh-kumar:feat/lightspeed-notebook-chat
Apr 28, 2026
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
29e2202
feat(lightspeed): create notebook flow
its-mitesh-kumar c0caa19
feat(lightspeed): creating new notebook
its-mitesh-kumar 05b0a79
updating status of documents
its-mitesh-kumar 104c86c
updating the unit tests
its-mitesh-kumar 5c9183b
handling overwrite in create flow
its-mitesh-kumar 2974885
adding changeset
its-mitesh-kumar f40fc10
feat(lightspeed): adding chat
its-mitesh-kumar e70c57b
delete of document
its-mitesh-kumar 1197cb0
Merge remote-tracking branch 'upstream' into feat/lightspeed-notebook…
its-mitesh-kumar f6290c1
formatting the query response
its-mitesh-kumar e859340
adding changeset
its-mitesh-kumar 43aee2d
updating delete functionality
its-mitesh-kumar 89c7ae7
fixing width
its-mitesh-kumar 3d278cc
improving spacing
its-mitesh-kumar 3faf3b9
update doc_url
its-mitesh-kumar 6eb0b4f
Merge branch 'main' into feat/lightspeed-notebook-chat
its-mitesh-kumar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
workspaces/lightspeed/.changeset/bright-notebooks-stream.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| '@red-hat-developer-hub/backstage-plugin-lightspeed': minor | ||
| '@red-hat-developer-hub/backstage-plugin-lightspeed-backend': patch | ||
| --- | ||
|
|
||
| Add notebook chat with streaming support, document management, and UI improvements. | ||
|
|
||
| - Backend: add SSE transform to normalize Responses API format to legacy streaming format so notebook chat streams token-by-token like the chat tab. | ||
| - Frontend: add notebook chat view with conversation messages, document sidebar with per-document delete, and topic summary display. | ||
| - Fix stale document list when re-opening a notebook by setting query staleTime to 0. | ||
| - Hide model selector on the Notebooks tab while keeping the settings ellipsis menu visible. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -205,4 +205,37 @@ export class NotebooksApiClient implements NotebooksAPI { | |
| `${baseUrl}/v1/sessions/${encodeURIComponent(sessionId)}/documents/${encodeURIComponent(documentId)}/status`, | ||
| ); | ||
| } | ||
|
|
||
| async querySession( | ||
| sessionId: string, | ||
| query: string, | ||
| ): Promise<ReadableStreamDefaultReader<Uint8Array>> { | ||
| const baseUrl = await this.getBaseUrl(); | ||
| const response = await this.fetchApi.fetch( | ||
| `${baseUrl}/v1/sessions/${encodeURIComponent(sessionId)}/query`, | ||
| { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify({ query }), | ||
| }, | ||
| ); | ||
|
|
||
| if (!response.body) { | ||
| throw new Error('Readable stream is not supported or there is no body.'); | ||
| } | ||
|
|
||
| if (!response.ok) { | ||
| const reader = response.body.getReader(); | ||
| const { done, value } = await reader.read(); | ||
| const text = done ? '' : new TextDecoder('utf-8').decode(value); | ||
| const errorMessage = JSON.parse(text); | ||
| if (errorMessage?.error) { | ||
| throw new Error( | ||
| `failed to query notebook session: ${errorMessage.error}`, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| return response.body.getReader(); | ||
| } | ||
|
Comment on lines
+227
to
+240
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Stream reader locked twice NotebooksApiClient.querySession() calls response.body.getReader() in the error path and then calls getReader() again to return a reader, which will throw because the stream is already locked and also may let non-OK responses proceed without throwing. Agent Prompt
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@JslYoon Please see if this changes looks good to you.
Notebook chat streaming: normalize SSE format to match chat tab
The notebook query endpoint proxies responses from Lightspeed Core, which uses the Responses API SSE format (
event: response.output_text.delta/data: {...}). However, the frontenduseConversationMessageshook expects the legacy streaming format (data: {"event": "token", "data": {"token": "..."}}), which is what the chat tab already uses.Without this transform, the frontend received the entire response as a single blob instead of streaming token-by-token, because it couldn't parse the incoming SSE events.
Added a
createResponsesApiTransforminnotebooksRouters.tsthat converts Responses API SSE events to the legacy format on the fly, so both chat and notebook tabs stream identically. The transform also captures theconversation_idfrom the firstresponse.createdevent and persists it on the session.Uh oh!
There was an error while loading. Please reload this page.
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.
That's fine by me.