From 37063f6a38e0959f7c7465cf05e010ba1d8511a5 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Thu, 26 Jan 2023 17:41:14 -0300 Subject: [PATCH] Truncate query to 8k chars for find similar notes from obsidian plugin Truncate current file data passed to khoj backend API via query string below default query size supported by popular servers --- src/interface/obsidian/src/modal.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/interface/obsidian/src/modal.ts b/src/interface/obsidian/src/modal.ts index 6d21a4f6..f1c9ef7c 100644 --- a/src/interface/obsidian/src/modal.ts +++ b/src/interface/obsidian/src/modal.ts @@ -63,8 +63,9 @@ export class KhojModal extends SuggestModal { if (file && file.extension === 'md') { // Enable rerank of search results this.rerank = true - // Set contents of active markdown file to input element - this.inputEl.value = await this.app.vault.read(file); + // Set input element to contents of active markdown file + // truncate to first 8,000 characters to avoid hitting query size limits + this.inputEl.value = await this.app.vault.read(file).then(file_str => file_str.slice(0, 8000)); // Trigger search to get and render similar notes from khoj backend this.inputEl.dispatchEvent(new Event('input')); this.rerank = false