Fix, improve displaying chat messages, sources by Khoj in web interface

Pretty pretty json in conversation logs
This commit is contained in:
Debanjum Singh Solanky
2023-03-14 11:24:47 -06:00
parent 6c0e82b2d6
commit 8609e3129e
2 changed files with 4 additions and 2 deletions

View File

@@ -219,7 +219,7 @@ def save_chat_session():
conversation_logfile = resolve_absolute_path(state.processor_config.conversation.conversation_logfile) conversation_logfile = resolve_absolute_path(state.processor_config.conversation.conversation_logfile)
conversation_logfile.parent.mkdir(parents=True, exist_ok=True) # create conversation directory if doesn't exist conversation_logfile.parent.mkdir(parents=True, exist_ok=True) # create conversation directory if doesn't exist
with open(conversation_logfile, "w+", encoding="utf-8") as logfile: with open(conversation_logfile, "w+", encoding="utf-8") as logfile:
json.dump(conversation_log, logfile) json.dump(conversation_log, logfile, indent=2)
state.processor_config.conversation.chat_session = None state.processor_config.conversation.chat_session = None
logger.info("📩 Saved current chat session to conversation logs") logger.info("📩 Saved current chat session to conversation logs")

View File

@@ -18,7 +18,8 @@
function generateReference(reference, index) { function generateReference(reference, index) {
// Generate HTML for Chat Reference // Generate HTML for Chat Reference
return `<sup><abbr title="${reference}" tabindex="0">${index}</abbr></sup>`; let escaped_ref = reference.replaceAll("\"", "\\\"")
return `<sup><abbr title="${escaped_ref}" tabindex="0">${index}</abbr></sup>`;
} }
function renderMessage(message, by, dt=null) { function renderMessage(message, by, dt=null) {
@@ -179,6 +180,7 @@
color: #f8fafc; color: #f8fafc;
background: #017eff; background: #017eff;
margin-left: auto; margin-left: auto;
white-space: pre-line;
} }
/* add left protrusion to khoj chat bubble */ /* add left protrusion to khoj chat bubble */
.chat-message-text.khoj:after { .chat-message-text.khoj:after {