diff --git a/manifest.json b/manifest.json index 7819708..3daaffd 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "smart-seeker", "name": "Smart Seeker", - "version": "0.1.25", + "version": "0.1.26", "minAppVersion": "0.15.0", "description": "A smart search plugin for Obsidian that helps you find document contents quickly and efficiently.", "author": "Obsidian", diff --git a/package.json b/package.json index e9e5303..6a8c20f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "smart-seeker", - "version": "0.1.25", + "version": "0.1.26", "description": "An Obsidian plugin that enables fast and intelligent note search using RAG (Retrieval Augmented Generation) with Pinecone vector database and OpenAI", "main": "main.js", "scripts": { diff --git a/src/helpers/utils/editorHelpers.ts b/src/helpers/utils/editorHelpers.ts index 8f1024b..bc7b7ab 100644 --- a/src/helpers/utils/editorHelpers.ts +++ b/src/helpers/utils/editorHelpers.ts @@ -91,3 +91,8 @@ export async function openNoteAndHighlightText( throw new Error("Failed to open file"); } } + +export function removeFrontmatter(content: string): string { + const frontmatterRegex = /^---\s*[\s\S]*?\s*---\s*/; + return content.replace(frontmatterRegex, ""); +} diff --git a/src/ui/RelatedNotesView/RelatedNotes.tsx b/src/ui/RelatedNotesView/RelatedNotes.tsx index 6b36c3d..cf494ef 100644 --- a/src/ui/RelatedNotesView/RelatedNotes.tsx +++ b/src/ui/RelatedNotesView/RelatedNotes.tsx @@ -7,6 +7,7 @@ import { Logger } from "@/helpers/logger"; import { openNote, openNoteAndHighlightText, + removeFrontmatter, } from "@/helpers/utils/editorHelpers"; import getEmbeddingModel from "@/helpers/utils/getEmbeddingModel"; import truncateContent from "@/helpers/utils/truncateContent"; @@ -74,9 +75,12 @@ const RelatedNotes = ({ currentFile }: RelatedNotesProps) => { queryFn: async () => { if (!currentFile) return []; const content = await app?.vault.cachedRead(currentFile); - // logger.debug("--→ content", content?.length, content); - if (!content || content.length < 50) return []; - const truncatedContent = truncateContent(content, 8192); + if (!content || !content?.length) return []; + + const title = currentFile.basename; + const cleanedContent = removeFrontmatter(content); + const query = `# ${title}\n\n${cleanedContent}`; + const truncatedContent = truncateContent(query, 8192); return queryByFileContent(truncatedContent || "", currentFile.path); }, enabled: diff --git a/versions.json b/versions.json index 7699769..87f1813 100644 --- a/versions.json +++ b/versions.json @@ -43,5 +43,6 @@ "0.1.22": "0.15.0", "0.1.23": "0.15.0", "0.1.24": "0.15.0", - "0.1.25": "0.15.0" + "0.1.25": "0.15.0", + "0.1.26": "0.15.0" } \ No newline at end of file