Skip to content

ui: Notebook Page#19339

Open
leszekhanusz wants to merge 62 commits into
ggml-org:masterfrom
leszekhanusz:notebook
Open

ui: Notebook Page#19339
leszekhanusz wants to merge 62 commits into
ggml-org:masterfrom
leszekhanusz:notebook

Conversation

@leszekhanusz

@leszekhanusz leszekhanusz commented Feb 4, 2026

Copy link
Copy Markdown

Close #23450

This PR adds a Notebook page to the llama.cpp webui which allows raw text generation instead of using the chat API.
It is useful for story generation and for debugging purposes.
Only a single notebook is available, it is not saved for now in localstorage.

Features:

  • allow to continue/abort generation of text in a separate notebook page
  • implementation of /completion api and /tokenize api calls
  • rudimentary undo/redo support which allows to undo only the last generation to quickly try something else
  • Ctrl-z, Ctrl-y, Shift-Enter keyboard shortcuts for quick generation/undo
  • auto-scroll during generation if enabled in settings
  • show generation statistics but also total context tokens if enabled in settings
  • Prevent browser to close the page directly if the notebook is not empty to avoid data loss
  • reusing the existing components to allow to change the selected model in router mode or show the current model settings if not
  • reusing the error dialog to show connection errors

This PR has been tested:

  • on desktop and on mobile
  • on dark and light themes
  • using router mode or not

Disclaimer:

  • the initial scaffolding, the new API calls, the auto-scroll has been generated using Gemini Pro with antigravity, but it has been verified, tested, corrected, heavily edited and directed by hand during the process to force it to reuse existing components instead of reinventing the wheel and I understand the generated code. I've read the Contributing guidelines and as an open-source maintainer I understand wanting to avoid a flood of AI-generated problematic code but I can assure you this is not a low-effort PR.

Remaining issues to discuss/plan:

  • renaming some components could be done now that they are used outside of the Chat context:
    • DialogChatSettings -> DialogSettings
    • DialogChatError -> DialogError
    • ChatMessageStatistics -> GenerationStatistics
      It has not been done here to not complicate further the code.
  • Also those two dialogs are duplicated in the Notebook page and the Chat page and they should be put on a single place to reduce the html size, maybe this should be better in a separate PR (better management of dialogs)
  • Adding Notebook to the Storybook and the webui/README.md and various diagrams
  • Currently using the tokenize method to get the total number of tokens, even if the display of stats is disabled. The display of total tokens could be put activated/deactivated a new parameter in the settings.
    ̶ T̶h̶e̶ ̶C̶o̶m̶p̶l̶e̶t̶i̶o̶n̶S̶e̶r̶v̶i̶c̶e̶ ̶a̶l̶l̶o̶w̶s̶ ̶b̶o̶t̶h̶ ̶s̶t̶r̶e̶a̶m̶ ̶a̶n̶d̶ ̶n̶o̶n̶-̶s̶t̶r̶e̶a̶m̶ ̶c̶a̶l̶l̶s̶,̶ ̶a̶s̶ ̶i̶t̶ ̶i̶s̶ ̶m̶o̶d̶e̶l̶e̶d̶ ̶a̶f̶t̶e̶r̶ ̶t̶h̶e̶ ̶C̶h̶a̶t̶S̶e̶r̶v̶i̶c̶e̶ ̶w̶h̶i̶c̶h̶ ̶d̶o̶e̶s̶ ̶t̶h̶e̶ ̶s̶a̶m̶e̶ ̶t̶h̶i̶n̶g̶.̶ ̶A̶s̶ ̶w̶e̶ ̶a̶r̶e̶ ̶u̶s̶i̶n̶g̶ ̶i̶t̶ ̶o̶n̶l̶y̶ ̶w̶i̶t̶h̶ ̶s̶t̶r̶e̶a̶m̶:̶t̶r̶u̶e̶ ̶w̶e̶ ̶c̶o̶u̶l̶d̶ ̶r̶e̶m̶o̶v̶e̶ ̶t̶h̶e̶ ̶n̶o̶n̶-̶s̶t̶r̶e̶a̶m̶ ̶h̶a̶n̶d̶l̶i̶n̶g̶?̶ REMOVED
  • We should add a truncate option in the settings which will only send the latest tokens to be able to continue past the maximum tokens of the model

I'll work on those remaining issues if there is interest in merging this PR.

Screenshots:

Peek.2026-02-04.18-37.webm

@ddh0

ddh0 commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Cool idea! I'd love to have something like this.

@allozaur

Copy link
Copy Markdown
Contributor

@allozaur Currently there is no truncation support (it just stops when we reach the maximum context), and we are sending the request as text. I think now that it would make more sense to always tokenize the notebook content and send tokens instead of text, and use the detokenize llama method afterwards. This is done this way on text-generation-webui to more easily truncate the prompt.

For the truncation strategy, I'm thinking about having two different parameters, truncate_to and truncate_from, which could accept either a token amount or a percentage. This way we could limit the number of times that the entire prompt is reprocessed. If the context_size and max_size parameters are available, truncate_from would default to context_size - max_size, and truncate_to would be something like 75% maybe.

Adding a new setting category in the settings for the notebook would be needed, with other options like a stop_text parameter which could be also interesting.

But this PR is already quite big so it might make sense to add those features in a follow-up PR. What do you think? Should I add them here (I could work on it from Tuesday) or is it better in another PR?

I think let's have them added in a follow up PR :) you can always base your new branch on this one and then rebase after this one is merged ;)

@leszekhanusz
leszekhanusz marked this pull request as ready for review March 17, 2026 17:26
@leszekhanusz
leszekhanusz requested a review from a team as a code owner March 17, 2026 17:26
@ddh0

ddh0 commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

Just popping up again to say that I'd really love this feature, and look forward to see it merged when ready. Thank you for the work.

@allozaur

Copy link
Copy Markdown
Contributor

Just popping up again to say that I'd really love this feature, and look forward to see it merged when ready. Thank you for the work.

Hey! I will be taking care of this PR in the upcoming week 😄

@allozaur

allozaur commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Guys, sorry for the late notice, but this PR will be worked on after merging #21237 as it introduces some UI/UX updates and it'd be good to align the Notebook to the updated look & feel. I'll keep u posted with the updates

@leszekhanusz

Copy link
Copy Markdown
Author

Note: I let Claude and Gemini deal with the complicated merge after moving from tools/server/webui to tools/ui and other master changes.

@allozaur

Copy link
Copy Markdown
Contributor

Hey @leszekhanusz can you please create a Feature issue for this feature? :) It's possible that it might hav some parent/sibling issues and one or more PRs related to it and I'm currently triaging and cleaning up some of the PM stuff in the project this week.

I'd appreciate any help with this :)

@leszekhanusz

Copy link
Copy Markdown
Author

Hey @leszekhanusz can you please create a Feature issue for this feature? :) It's possible that it might hav some parent/sibling issues and one or more PRs related to it and I'm currently triaging and cleaning up some of the PM stuff in the project this week.

Sure! I made the issue #23450

@allozaur allozaur changed the title Notebook page on webui ui: Notebook Page May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Notebook page on llama-ui

4 participants