Render conversation logs on page load

This commit is contained in:
Debanjum Singh Solanky 2023-03-23 08:16:54 +04:00
parent cd46a17e5f
commit 1d3d949962

View file

@ -20,6 +20,14 @@ export class KhojChatModal extends Modal {
// Create area for chat logs
contentEl.createDiv({ attr: { class: "chat-body" } });
// Get conversation history from Khoj backend
let chatUrl = `${this.setting.khojUrl}/api/chat?`;
let response = await request(chatUrl);
let chatLogs = JSON.parse(response).response;
chatLogs.forEach( (chatLog: any) => {
this.renderMessage(chatLog.message, chatLog.by);
});
// Add chat input field
new Setting(contentEl)
.addText((text) => {