Fix rendering images from Khoj response in Obsidian client

This commit is contained in:
Debanjum Singh Solanky
2024-02-25 00:11:11 +05:30
parent 0e0e751ef7
commit 9b61f0b5f7

View File

@@ -398,7 +398,7 @@ export class KhojChatModal extends Modal {
// Reset collated chat result to empty string // Reset collated chat result to empty string
this.result = ""; this.result = "";
responseElement.innerHTML = ""; responseElement.innerHTML = "";
if (response.headers.get("content-type") == "application/json") { if (response.headers.get("content-type") === "application/json") {
let responseText = "" let responseText = ""
try { try {
const responseAsJson = await response.json() as ChatJsonResult; const responseAsJson = await response.json() as ChatJsonResult;
@@ -413,10 +413,10 @@ export class KhojChatModal extends Modal {
} finally { } finally {
await this.renderIncrementalMessage(responseElement, responseText); await this.renderIncrementalMessage(responseElement, responseText);
} }
} } else {
// Stream and render chat response // Stream and render chat response
await this.readChatStream(response, responseElement); await this.readChatStream(response, responseElement);
}
} catch (err) { } catch (err) {
console.log(`Khoj chat response failed with\n${err}`); console.log(`Khoj chat response failed with\n${err}`);
let errorMsg = "Sorry, unable to get response from Khoj backend ❤️‍🩹. Retry or contact developers for help at <a href=mailto:'team@khoj.dev'>team@khoj.dev</a> or <a href='https://discord.gg/BDgyabRM6e'>on Discord</a>"; let errorMsg = "Sorry, unable to get response from Khoj backend ❤️‍🩹. Retry or contact developers for help at <a href=mailto:'team@khoj.dev'>team@khoj.dev</a> or <a href='https://discord.gg/BDgyabRM6e'>on Discord</a>";