Update src/chat_display.py
Browse files- src/chat_display.py +18 -2
src/chat_display.py
CHANGED
|
@@ -5,6 +5,7 @@ This module handles the chat display components and rendering.
|
|
| 5 |
import streamlit as st
|
| 6 |
import os
|
| 7 |
from utils import has_meaningful_content, remove_reasoning_and_sources, clean_explanation, get_image_base64
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
def get_avatars():
|
|
@@ -31,11 +32,26 @@ def get_avatars():
|
|
| 31 |
|
| 32 |
def display_chat_history():
|
| 33 |
"""
|
| 34 |
-
Display the chat history from
|
| 35 |
"""
|
| 36 |
user_avatar, assistant_avatar = get_avatars()
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
if message["role"] == "user":
|
| 40 |
# Right-aligned container for user messages
|
| 41 |
with st.container():
|
|
|
|
| 5 |
import streamlit as st
|
| 6 |
import os
|
| 7 |
from utils import has_meaningful_content, remove_reasoning_and_sources, clean_explanation, get_image_base64
|
| 8 |
+
from session_state import get_full_history
|
| 9 |
|
| 10 |
|
| 11 |
def get_avatars():
|
|
|
|
| 32 |
|
| 33 |
def display_chat_history():
|
| 34 |
"""
|
| 35 |
+
Display the chat history from the database.
|
| 36 |
"""
|
| 37 |
user_avatar, assistant_avatar = get_avatars()
|
| 38 |
|
| 39 |
+
# Get full history from database
|
| 40 |
+
history = get_full_history()
|
| 41 |
+
|
| 42 |
+
# Show message count for debugging
|
| 43 |
+
# st.caption(f"Displaying {len(history)} messages")
|
| 44 |
+
|
| 45 |
+
# Option to display a limited number of recent messages (UI performance)
|
| 46 |
+
# Configure this as needed based on your UI requirements
|
| 47 |
+
max_display_messages = 20
|
| 48 |
+
display_history = history[-max_display_messages:] if len(history) > max_display_messages else history
|
| 49 |
+
|
| 50 |
+
# Show indicator if some messages are hidden
|
| 51 |
+
if len(history) > max_display_messages:
|
| 52 |
+
st.caption(f"Showing most recent {max_display_messages} of {len(history)} messages")
|
| 53 |
+
|
| 54 |
+
for message in display_history:
|
| 55 |
if message["role"] == "user":
|
| 56 |
# Right-aligned container for user messages
|
| 57 |
with st.container():
|