feat(llm): add knowledge base mode for source-grounded conversations#9343
Draft
Kureii wants to merge 2 commits intoTriliumNext:mainfrom
Draft
feat(llm): add knowledge base mode for source-grounded conversations#9343Kureii wants to merge 2 commits intoTriliumNext:mainfrom
Kureii wants to merge 2 commits intoTriliumNext:mainfrom
Conversation
Add a Knowledge Base feature that allows users to select specific notes as context sources for LLM conversations. The AI uses these notes as primary reference material, providing Harvard-style citations. - Add KB panel in ChatInputBar with note autocomplete and chip display - Add buildKnowledgeBaseSources() for extended content previews - Enable note tools automatically when KB sources are selected - Add sourceNoteIds to chat config and state persistence - Add KB documentation page and translation keys
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a 'Knowledge Base' feature for the AI chat, allowing users to select specific notes as sources for AI responses. The changes include UI components for managing these sources, backend logic to incorporate note previews and metadata into the system prompt, and necessary type definitions. I have provided feedback regarding the use of !important in CSS and suggested simplifying the logic for generating content previews in the backend.
Build extended preview directly from note content instead of calling getContentPreview() first and then re-fetching for longer preview. Removes unused getContentPreview import.
eliandoran
requested changes
Apr 11, 2026
Contributor
There was a problem hiding this comment.
- Toggling "Knowledge base" on or off completely wipes the source note IDs. Is this intended?
- The references could use a UI/UX improvement. I would suggest taking inspiration from the already existing sources indicator that appears for web searches. Make sure not to create too much duplication.
- The contrast of the "Knowledge base sources" on the dark theme is not that great.
Contributor
There was a problem hiding this comment.
Too many changes to an already big file, extract to a separate component with its own stylesheet.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Add a Knowledge Base feature that allows users to select specific notes as context sources for LLM conversations. The AI uses these notes as primary reference material with Harvard-style numbered citations.
Changes
ChatInputBarbuildKnowledgeBaseSources()injects extended content previews (up to 1500 chars per note) with numbered reference lists[1],[2]with a## Referencessection linking back to notes via[[noteId]]sourceNoteIdspersisted in chat content and restored on loadFiles (9 files, +392/-8)
apps/server/src/services/llm/providers/base_provider.ts- KB system prompt + tool enablementapps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts-sourceNoteIdsstate + persistenceapps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx- KB panel UIapps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.css- KB stylingapps/client/src/widgets/type_widgets/llm_chat/llm_chat_types.ts-sourceNoteIdsfieldapps/client/src/services/note_autocomplete.ts-closeOnBluroptionpackages/commons/src/lib/llm_api.ts-sourceNoteIdson configapps/client/src/translations/en/translation.json- KB translation keysdocs/.../AI/Knowledge Base.html- New: Documentation page