mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-05 13:21:18 +00:00
Merge branch 'master' of github.com:khoj-ai/khoj into HEAD
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "khoj",
|
||||
"name": "Khoj",
|
||||
"version": "1.33.2",
|
||||
"version": "1.34.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Your Second Brain",
|
||||
"author": "Khoj Inc.",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Khoj",
|
||||
"version": "1.33.2",
|
||||
"version": "1.34.0",
|
||||
"description": "Your Second Brain",
|
||||
"author": "Debanjum Singh Solanky, Saba Imran <team@khoj.dev>",
|
||||
"license": "GPL-3.0-or-later",
|
||||
|
||||
@@ -501,6 +501,7 @@ export class KhojChatView extends KhojPaneView {
|
||||
conversationId?: string,
|
||||
images?: string[],
|
||||
excalidrawDiagram?: string,
|
||||
mermaidjsDiagram?: string
|
||||
) {
|
||||
if (!message) return;
|
||||
|
||||
@@ -509,8 +510,9 @@ export class KhojChatView extends KhojPaneView {
|
||||
intentType?.includes("text-to-image") ||
|
||||
intentType === "excalidraw" ||
|
||||
(images && images.length > 0) ||
|
||||
mermaidjsDiagram ||
|
||||
excalidrawDiagram) {
|
||||
let imageMarkdown = this.generateImageMarkdown(message, intentType ?? "", inferredQueries, conversationId, images, excalidrawDiagram);
|
||||
let imageMarkdown = this.generateImageMarkdown(message, intentType ?? "", inferredQueries, conversationId, images, excalidrawDiagram, mermaidjsDiagram);
|
||||
chatMessageEl = this.renderMessage({
|
||||
chatBodyEl: chatEl,
|
||||
message: imageMarkdown,
|
||||
@@ -542,28 +544,23 @@ export class KhojChatView extends KhojPaneView {
|
||||
chatMessageBodyEl.appendChild(this.createReferenceSection(references));
|
||||
}
|
||||
|
||||
generateImageMarkdown(message: string, intentType: string, inferredQueries?: string[], conversationId?: string, images?: string[], excalidrawDiagram?: string): string {
|
||||
generateImageMarkdown(message: string, intentType: string, inferredQueries?: string[], conversationId?: string, images?: string[], excalidrawDiagram?: string, mermaidjsDiagram?: string): string {
|
||||
let imageMarkdown = "";
|
||||
if (intentType === "text-to-image") {
|
||||
imageMarkdown = ``;
|
||||
} else if (intentType === "text-to-image2") {
|
||||
imageMarkdown = ``;
|
||||
} else if (intentType === "text-to-image-v3") {
|
||||
imageMarkdown = ``;
|
||||
imageMarkdown = ``;
|
||||
} else if (intentType === "excalidraw" || excalidrawDiagram) {
|
||||
const domain = this.setting.khojUrl.endsWith("/") ? this.setting.khojUrl : `${this.setting.khojUrl}/`;
|
||||
const redirectMessage = `Hey, I'm not ready to show you diagrams yet here. But you can view it in ${domain}chat?conversationId=${conversationId}`;
|
||||
imageMarkdown = redirectMessage;
|
||||
} else if (mermaidjsDiagram) {
|
||||
imageMarkdown = "```mermaid\n" + mermaidjsDiagram + "\n```";
|
||||
} else if (images && images.length > 0) {
|
||||
for (let image of images) {
|
||||
if (image.startsWith("https://")) {
|
||||
imageMarkdown += `\n\n`;
|
||||
} else {
|
||||
imageMarkdown += `\n\n`;
|
||||
}
|
||||
}
|
||||
|
||||
imageMarkdown += `${message}`;
|
||||
imageMarkdown += images.map(image => ``).join('\n\n');
|
||||
imageMarkdown += message;
|
||||
}
|
||||
|
||||
if (images?.length === 0 && inferredQueries) {
|
||||
@@ -961,6 +958,7 @@ export class KhojChatView extends KhojPaneView {
|
||||
chatBodyEl.dataset.conversationId ?? "",
|
||||
chatLog.images,
|
||||
chatLog.excalidrawDiagram,
|
||||
chatLog.mermaidjsDiagram,
|
||||
);
|
||||
// push the user messages to the chat history
|
||||
if (chatLog.by === "you") {
|
||||
@@ -1077,7 +1075,7 @@ export class KhojChatView extends KhojPaneView {
|
||||
}
|
||||
|
||||
handleJsonResponse(jsonData: any): void {
|
||||
if (jsonData.image || jsonData.detail || jsonData.images || jsonData.excalidrawDiagram) {
|
||||
if (jsonData.image || jsonData.detail || jsonData.images || jsonData.mermaidjsDiagram) {
|
||||
this.chatMessageState.rawResponse = this.handleImageResponse(jsonData, this.chatMessageState.rawResponse);
|
||||
} else if (jsonData.response) {
|
||||
this.chatMessageState.rawResponse = jsonData.response;
|
||||
@@ -1450,7 +1448,7 @@ export class KhojChatView extends KhojPaneView {
|
||||
} else if (imageJson.intentType === "text-to-image2") {
|
||||
rawResponse += ``;
|
||||
} else if (imageJson.intentType === "text-to-image-v3") {
|
||||
rawResponse = ``;
|
||||
rawResponse = ``;
|
||||
} else if (imageJson.intentType === "excalidraw") {
|
||||
const domain = this.setting.khojUrl.endsWith("/") ? this.setting.khojUrl : `${this.setting.khojUrl}/`;
|
||||
const redirectMessage = `Hey, I'm not ready to show you diagrams yet here. But you can view it in ${domain}`;
|
||||
@@ -1462,17 +1460,14 @@ export class KhojChatView extends KhojPaneView {
|
||||
} else if (imageJson.images) {
|
||||
// If response has images field, response is a list of generated images.
|
||||
imageJson.images.forEach((image: any) => {
|
||||
|
||||
if (image.startsWith("http")) {
|
||||
rawResponse += `\n\n`;
|
||||
} else {
|
||||
rawResponse += `\n\n`;
|
||||
}
|
||||
rawResponse += `\n\n`;
|
||||
});
|
||||
} else if (imageJson.excalidrawDiagram) {
|
||||
const domain = this.setting.khojUrl.endsWith("/") ? this.setting.khojUrl : `${this.setting.khojUrl}/`;
|
||||
const redirectMessage = `Hey, I'm not ready to show you diagrams yet here. But you can view it in ${domain}`;
|
||||
rawResponse += redirectMessage;
|
||||
} else if (imageJson.mermaidjsDiagram) {
|
||||
rawResponse += imageJson.mermaidjsDiagram;
|
||||
}
|
||||
|
||||
// If response has detail field, response is an error message.
|
||||
|
||||
@@ -108,5 +108,6 @@
|
||||
"1.32.2": "0.15.0",
|
||||
"1.33.0": "0.15.0",
|
||||
"1.33.1": "0.15.0",
|
||||
"1.33.2": "0.15.0"
|
||||
"1.33.2": "0.15.0",
|
||||
"1.34.0": "0.15.0"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user