Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -103,20 +103,31 @@ chat = RunnableWithMessageHistory(
|
|
| 103 |
)
|
| 104 |
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
# Load chat history and keep it sticky
|
| 108 |
if "messages" not in st.session_state:
|
| 109 |
st.session_state.messages = load_chat_history(session_id)
|
| 110 |
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
# Display chat history
|
| 113 |
|
| 114 |
for role, content in st.session_state.messages:
|
| 115 |
with st.chat_message(role):
|
| 116 |
st.markdown(content)
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
|
|
|
| 120 |
|
| 121 |
if user_input:
|
| 122 |
# Save user message
|
|
|
|
| 103 |
)
|
| 104 |
|
| 105 |
|
| 106 |
+
# 🔹 Chat history container
|
| 107 |
+
chat_container = st.container()
|
| 108 |
+
|
| 109 |
+
# 🔹 Always keep input box at the bottom
|
| 110 |
+
input_container = st.empty()
|
| 111 |
|
| 112 |
# Load chat history and keep it sticky
|
| 113 |
if "messages" not in st.session_state:
|
| 114 |
st.session_state.messages = load_chat_history(session_id)
|
| 115 |
|
| 116 |
|
| 117 |
+
# Display chat messages in order
|
| 118 |
+
with chat_container:
|
| 119 |
+
for role, content in st.session_state.messages:
|
| 120 |
+
with st.chat_message(role):
|
| 121 |
+
st.markdown(content)
|
| 122 |
# Display chat history
|
| 123 |
|
| 124 |
for role, content in st.session_state.messages:
|
| 125 |
with st.chat_message(role):
|
| 126 |
st.markdown(content)
|
| 127 |
|
| 128 |
+
with input_container:
|
| 129 |
+
# User input at the bottom
|
| 130 |
+
user_input = st.text_input("Type your message here:", key="user_message")
|
| 131 |
|
| 132 |
if user_input:
|
| 133 |
# Save user message
|