mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 05:39:12 +00:00
Merge pull request #265 from khoj-ai/fix/obsidian-setup-issues
Fix configuration setup logic in Obsidian
This commit is contained in:
@@ -161,7 +161,7 @@ export class KhojSearchModal extends SuggestModal<SearchResult> {
|
|||||||
// Open vault file at heading of chosen search result
|
// Open vault file at heading of chosen search result
|
||||||
if (file_match) {
|
if (file_match) {
|
||||||
let resultHeading = file_match.extension !== 'pdf' ? result.entry.split('\n', 1)[0] : '';
|
let resultHeading = file_match.extension !== 'pdf' ? result.entry.split('\n', 1)[0] : '';
|
||||||
let linkToEntry = `${file_match.path}${resultHeading}`
|
let linkToEntry = resultHeading.startsWith('#') ? `${file_match.path}${resultHeading}` : file_match.path;
|
||||||
this.app.workspace.openLinkText(linkToEntry, '');
|
this.app.workspace.openLinkText(linkToEntry, '');
|
||||||
console.log(`Link: ${linkToEntry}, File: ${file_match.path}, Heading: ${resultHeading}`);
|
console.log(`Link: ${linkToEntry}, File: ${file_match.path}, Heading: ${resultHeading}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,41 +72,58 @@ export async function configureKhojBackend(vault: Vault, setting: KhojSetting, n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Else if khoj is not configured to index markdown files in configured obsidian vault
|
// Else if khoj is not configured to index markdown files in configured obsidian vault
|
||||||
else if (data["content-type"]["markdown"]["input-filter"].length != 1 ||
|
else if (
|
||||||
|
data["content-type"]["markdown"]["input-files"] != null ||
|
||||||
|
data["content-type"]["markdown"]["input-filter"] == null ||
|
||||||
|
data["content-type"]["markdown"]["input-filter"].length != 1 ||
|
||||||
data["content-type"]["markdown"]["input-filter"][0] !== mdInVault) {
|
data["content-type"]["markdown"]["input-filter"][0] !== mdInVault) {
|
||||||
// Update markdown config in khoj content-type config
|
// Update markdown config in khoj content-type config
|
||||||
// Set markdown config to only index markdown files in configured obsidian vault
|
// Set markdown config to only index markdown files in configured obsidian vault
|
||||||
let khojMdIndexDirectory = getIndexDirectoryFromBackendConfig(data["content-type"]["markdown"]["embeddings-file"]);
|
let khojMdIndexDirectory = getIndexDirectoryFromBackendConfig(data["content-type"]["markdown"]["embeddings-file"]);
|
||||||
data["content-type"]["markdown"] = {
|
data["content-type"]["markdown"] = {
|
||||||
"input-filter": [mdInVault],
|
"input-filter": [mdInVault],
|
||||||
"input-files": null,
|
"input-files": null,
|
||||||
"embeddings-file": `${khojMdIndexDirectory}/${indexName}.pt`,
|
"embeddings-file": `${khojMdIndexDirectory}/${indexName}.pt`,
|
||||||
"compressed-jsonl": `${khojMdIndexDirectory}/${indexName}.jsonl.gz`,
|
"compressed-jsonl": `${khojMdIndexDirectory}/${indexName}.jsonl.gz`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (khoj_already_configured && !data["content-type"]["pdf"]) {
|
if (khoj_already_configured && !data["content-type"]["pdf"]) {
|
||||||
// Add pdf config to khoj content-type config
|
const hasPdfFiles = app.vault.getFiles().some(file => file.extension === 'pdf');
|
||||||
// Set pdf config to index pdf files in configured obsidian vault
|
|
||||||
data["content-type"]["pdf"] = {
|
if (hasPdfFiles) {
|
||||||
"input-filter": [pdfInVault],
|
data["content-type"]["pdf"] = {
|
||||||
"input-files": null,
|
"input-filter": [pdfInVault],
|
||||||
"embeddings-file": `${khojDefaultPdfIndexDirectory}/${indexName}.pt`,
|
"input-files": null,
|
||||||
"compressed-jsonl": `${khojDefaultPdfIndexDirectory}/${indexName}.jsonl.gz`,
|
"embeddings-file": `${khojDefaultPdfIndexDirectory}/${indexName}.pt`,
|
||||||
|
"compressed-jsonl": `${khojDefaultPdfIndexDirectory}/${indexName}.jsonl.gz`,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data["content-type"]["pdf"] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Else if khoj is not configured to index pdf files in configured obsidian vault
|
// Else if khoj is not configured to index pdf files in configured obsidian vault
|
||||||
else if (khoj_already_configured &&
|
else if (khoj_already_configured &&
|
||||||
(data["content-type"]["pdf"]["input-filter"].length != 1 ||
|
(
|
||||||
data["content-type"]["pdf"]["input-filter"][0] !== pdfInVault)) {
|
data["content-type"]["pdf"]["input-files"] != null ||
|
||||||
// Update pdf config in khoj content-type config
|
data["content-type"]["pdf"]["input-filter"] == null ||
|
||||||
// Set pdf config to only index pdf files in configured obsidian vault
|
data["content-type"]["pdf"]["input-filter"].length != 1 ||
|
||||||
let khojPdfIndexDirectory = getIndexDirectoryFromBackendConfig(data["content-type"]["pdf"]["embeddings-file"]);
|
data["content-type"]["pdf"]["input-filter"][0] !== pdfInVault)) {
|
||||||
data["content-type"]["pdf"] = {
|
|
||||||
"input-filter": [pdfInVault],
|
let hasPdfFiles = app.vault.getFiles().some(file => file.extension === 'pdf');
|
||||||
"input-files": null,
|
|
||||||
"embeddings-file": `${khojPdfIndexDirectory}/${indexName}.pt`,
|
if (hasPdfFiles) {
|
||||||
"compressed-jsonl": `${khojPdfIndexDirectory}/${indexName}.jsonl.gz`,
|
// Update pdf config in khoj content-type config
|
||||||
|
// Set pdf config to only index pdf files in configured obsidian vault
|
||||||
|
let khojPdfIndexDirectory = getIndexDirectoryFromBackendConfig(data["content-type"]["pdf"]["embeddings-file"]);
|
||||||
|
data["content-type"]["pdf"] = {
|
||||||
|
"input-filter": [pdfInVault],
|
||||||
|
"input-files": null,
|
||||||
|
"embeddings-file": `${khojPdfIndexDirectory}/${indexName}.pt`,
|
||||||
|
"compressed-jsonl": `${khojPdfIndexDirectory}/${indexName}.jsonl.gz`,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data["content-type"]["pdf"] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user