Skip to content

Build your personal knowledge base with Trilium Notes

feat(llm): add content preview & parent title to search

Elian Doran325dc9c8a8f6
diff --git a/apps/server/src/services/llm/tools/note_tools.ts b/apps/server/src/services/llm/tools/note_tools.ts
index d37017ec9d..7c0405ad0e 100644
--- a/apps/server/src/services/llm/tools/note_tools.ts
+++ b/apps/server/src/services/llm/tools/note_tools.ts
@@ -9,7 +9,7 @@ import markdownImport from "../../import/markdown.js";
import noteService from "../../notes.js";
import SearchContext from "../../search/search_context.js";
import searchService from "../../search/services/search.js";
-import { getNoteContentForLlm, getNoteMeta, setNoteContentFromLlm } from "./helpers.js";
+import { getContentPreview, getNoteContentForLlm, getNoteMeta, setNoteContentFromLlm } from "./helpers.js";
import { defineTools } from "./tool_registry.js";
export const noteTools = defineTools({
@@ -43,10 +43,13 @@ export const noteTools = defineTools({
return results.slice(0, limit).map(sr => {
const note = becca.notes[sr.noteId];
if (!note) return null;
+ const parentNote = note.getParentNotes()[0];
return {
noteId: note.noteId,
title: note.getTitleOrProtected(),
- type: note.type
+ type: note.type,
+ parentTitle: parentNote?.getTitleOrProtected() ?? null,
+ contentPreview: getContentPreview(note)
};
}).filter(Boolean);
}