|
1 | | -from utils import load_yaml_file_with_db_prompts |
| 1 | +from utils import load_yaml_file_with_db_prompts, escape_markdown |
2 | 2 | from main import get_ragchain |
3 | 3 | import streamlit as st |
4 | 4 | from menu import menu_with_redirect |
@@ -81,7 +81,7 @@ def save_feedback(username, msg_idx, feedback_type, response_snippet, reason=Non |
81 | 81 | # ------------------------------- |
82 | 82 | for idx, message in enumerate(user_chat): |
83 | 83 | with st.chat_message(message["role"], avatar=logo_path if message["role"] == "assistant" else None): |
84 | | - st.write(message["content"]) |
| 84 | + st.markdown(escape_markdown(message["content"])) |
85 | 85 | # Only show feedback for assistant messages that are not the initial greeting |
86 | 86 | if message["role"] == "assistant" and not (idx == 0 and message["content"] == "How may I help you?"): |
87 | 87 | feedback_key = f"feedback_{username}_{idx}" |
@@ -147,7 +147,7 @@ def save_feedback(username, msg_idx, feedback_type, response_snippet, reason=Non |
147 | 147 | save_message(username, "user", prompt) |
148 | 148 |
|
149 | 149 | with st.chat_message("user"): |
150 | | - st.write(prompt) |
| 150 | + st.markdown(escape_markdown(prompt)) |
151 | 151 |
|
152 | 152 | with st.chat_message("assistant", avatar=logo_path): |
153 | 153 | with st.spinner("Thinking..."): |
@@ -197,7 +197,7 @@ def save_feedback(username, msg_idx, feedback_type, response_snippet, reason=Non |
197 | 197 |
|
198 | 198 | # Keep text file backup for now (can be removed later) |
199 | 199 | print(response, file=open('responses.txt', 'a', encoding='utf-8')) |
200 | | - st.markdown(response["answer"]) |
| 200 | + st.markdown(escape_markdown(response["answer"])) |
201 | 201 |
|
202 | 202 | reply_msg = {"role": "assistant", "content": response["answer"]} |
203 | 203 | user_chat.append(reply_msg) |
|
0 commit comments