mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-18 18:47:11 +00:00
Ensure that the generated assets are maintained in the chat window after streaming is completed.
This commit is contained in:
parent
e3aee50cf3
commit
dc4a9ee3e1
1 changed files with 5 additions and 2 deletions
|
@ -27,6 +27,7 @@ interface ChatMessageState {
|
||||||
newResponseEl: HTMLElement | null;
|
newResponseEl: HTMLElement | null;
|
||||||
loadingEllipsis: HTMLElement | null;
|
loadingEllipsis: HTMLElement | null;
|
||||||
references: any;
|
references: any;
|
||||||
|
generatedAssets: string;
|
||||||
rawResponse: string;
|
rawResponse: string;
|
||||||
rawQuery: string;
|
rawQuery: string;
|
||||||
isVoice: boolean;
|
isVoice: boolean;
|
||||||
|
@ -961,6 +962,7 @@ export class KhojChatView extends KhojPaneView {
|
||||||
} else if (chunk.type === 'generated_assets') {
|
} else if (chunk.type === 'generated_assets') {
|
||||||
const generatedAssets = chunk.data;
|
const generatedAssets = chunk.data;
|
||||||
const imageData = this.handleImageResponse(generatedAssets, this.chatMessageState.rawResponse);
|
const imageData = this.handleImageResponse(generatedAssets, this.chatMessageState.rawResponse);
|
||||||
|
this.chatMessageState.generatedAssets = imageData;
|
||||||
this.handleStreamResponse(this.chatMessageState.newResponseTextEl, imageData, this.chatMessageState.loadingEllipsis, false);
|
this.handleStreamResponse(this.chatMessageState.newResponseTextEl, imageData, this.chatMessageState.loadingEllipsis, false);
|
||||||
} else if (chunk.type === 'start_llm_response') {
|
} else if (chunk.type === 'start_llm_response') {
|
||||||
console.log("Started streaming", new Date());
|
console.log("Started streaming", new Date());
|
||||||
|
@ -984,6 +986,7 @@ export class KhojChatView extends KhojPaneView {
|
||||||
rawResponse: "",
|
rawResponse: "",
|
||||||
rawQuery: liveQuery,
|
rawQuery: liveQuery,
|
||||||
isVoice: false,
|
isVoice: false,
|
||||||
|
generatedAssets: "",
|
||||||
};
|
};
|
||||||
} else if (chunk.type === "references") {
|
} else if (chunk.type === "references") {
|
||||||
this.chatMessageState.references = { "notes": chunk.data.context, "online": chunk.data.onlineContext };
|
this.chatMessageState.references = { "notes": chunk.data.context, "online": chunk.data.onlineContext };
|
||||||
|
@ -999,11 +1002,11 @@ export class KhojChatView extends KhojPaneView {
|
||||||
this.handleJsonResponse(jsonData);
|
this.handleJsonResponse(jsonData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.chatMessageState.rawResponse += chunkData;
|
this.chatMessageState.rawResponse += chunkData;
|
||||||
this.handleStreamResponse(this.chatMessageState.newResponseTextEl, this.chatMessageState.rawResponse, this.chatMessageState.loadingEllipsis);
|
this.handleStreamResponse(this.chatMessageState.newResponseTextEl, this.chatMessageState.rawResponse + this.chatMessageState.generatedAssets, this.chatMessageState.loadingEllipsis);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.chatMessageState.rawResponse += chunkData;
|
this.chatMessageState.rawResponse += chunkData;
|
||||||
this.handleStreamResponse(this.chatMessageState.newResponseTextEl, this.chatMessageState.rawResponse, this.chatMessageState.loadingEllipsis);
|
this.handleStreamResponse(this.chatMessageState.newResponseTextEl, this.chatMessageState.rawResponse + this.chatMessageState.generatedAssets, this.chatMessageState.loadingEllipsis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue