mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Set client request param when calling khoj server APIs from Obsidian
This commit is contained in:
@@ -35,7 +35,7 @@ export class KhojChatModal extends Modal {
|
|||||||
contentEl.createDiv({ attr: { id: "khoj-chat-body", class: "khoj-chat-body" } });
|
contentEl.createDiv({ attr: { id: "khoj-chat-body", class: "khoj-chat-body" } });
|
||||||
|
|
||||||
// Get conversation history from Khoj backend
|
// Get conversation history from Khoj backend
|
||||||
let chatUrl = `${this.setting.khojUrl}/api/chat?`;
|
let chatUrl = `${this.setting.khojUrl}/api/chat?client=obsidian`;
|
||||||
let response = await request(chatUrl);
|
let response = await request(chatUrl);
|
||||||
let chatLogs = JSON.parse(response).response;
|
let chatLogs = JSON.parse(response).response;
|
||||||
chatLogs.forEach((chatLog: any) => {
|
chatLogs.forEach((chatLog: any) => {
|
||||||
@@ -120,7 +120,7 @@ export class KhojChatModal extends Modal {
|
|||||||
|
|
||||||
// Get chat response from Khoj backend
|
// Get chat response from Khoj backend
|
||||||
let encodedQuery = encodeURIComponent(query);
|
let encodedQuery = encodeURIComponent(query);
|
||||||
let chatUrl = `${this.setting.khojUrl}/api/chat?q=${encodedQuery}`;
|
let chatUrl = `${this.setting.khojUrl}/api/chat?q=${encodedQuery}&client=obsidian`;
|
||||||
let response = await request(chatUrl);
|
let response = await request(chatUrl);
|
||||||
let data = JSON.parse(response);
|
let data = JSON.parse(response);
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ export class KhojSearchModal extends SuggestModal<SearchResult> {
|
|||||||
async getSuggestions(query: string): Promise<SearchResult[]> {
|
async getSuggestions(query: string): Promise<SearchResult[]> {
|
||||||
// Query Khoj backend for search results
|
// Query Khoj backend for search results
|
||||||
let encodedQuery = encodeURIComponent(query);
|
let encodedQuery = encodeURIComponent(query);
|
||||||
let searchUrl = `${this.setting.khojUrl}/api/search?q=${encodedQuery}&n=${this.setting.resultsCount}&r=${this.rerank}`;
|
let searchUrl = `${this.setting.khojUrl}/api/search?q=${encodedQuery}&n=${this.setting.resultsCount}&r=${this.rerank}&client=obsidian`;
|
||||||
|
|
||||||
// Get search results for markdown and pdf files
|
// Get search results for markdown and pdf files
|
||||||
let mdResponse = await request(`${searchUrl}&t=markdown`);
|
let mdResponse = await request(`${searchUrl}&t=markdown`);
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ export class KhojSettingTab extends PluginSettingTab {
|
|||||||
}, 300);
|
}, 300);
|
||||||
this.plugin.registerInterval(progress_indicator);
|
this.plugin.registerInterval(progress_indicator);
|
||||||
|
|
||||||
await request(`${this.plugin.settings.khojUrl}/api/update?t=markdown&force=true`);
|
await request(`${this.plugin.settings.khojUrl}/api/update?t=markdown&force=true&client=obsidian`);
|
||||||
await request(`${this.plugin.settings.khojUrl}/api/update?t=pdf&force=true`);
|
await request(`${this.plugin.settings.khojUrl}/api/update?t=pdf&force=true&client=obsidian`);
|
||||||
new Notice('✅ Updated Khoj index.');
|
new Notice('✅ Updated Khoj index.');
|
||||||
|
|
||||||
// Reset button once index is updated
|
// Reset button once index is updated
|
||||||
|
|||||||
Reference in New Issue
Block a user