Skip to content

Build your personal knowledge base with Trilium Notes

fix(llm): dedupe search_help words without tripping tsc --build

Elian Doranb42e6347865c
diff --git a/apps/server/src/services/llm/tools/help_tools.ts b/apps/server/src/services/llm/tools/help_tools.ts
index 254fe3699a..c77aa2a207 100644
--- a/apps/server/src/services/llm/tools/help_tools.ts
+++ b/apps/server/src/services/llm/tools/help_tools.ts
@@ -43,9 +43,11 @@ export const helpTools = defineTools({
// Strip punctuation (models happily send "cloning?" despite the
// schema hint) and deduplicate so repeated words don't skew scoring.
- const words = [...new Set(
- query.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, " ").split(/\s+/).filter(Boolean)
- )];
+ const words = query.toLowerCase()
+ .replace(/[^\p{L}\p{N}\s]/gu, " ")
+ .split(/\s+/)
+ .filter(Boolean)
+ .filter((word, index, all) => all.indexOf(word) === index);
if (words.length === 0) {
return { error: "Empty search query." };
}