Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -63,8 +63,8 @@ st.markdown("""
|
|
63 |
display: flex;
|
64 |
flex-direction: column;
|
65 |
justify-content: flex-end;
|
66 |
-
height: calc(100vh -
|
67 |
-
margin-bottom:
|
68 |
}
|
69 |
.chat-history-wrapper {
|
70 |
flex-grow: 1;
|
@@ -89,7 +89,6 @@ st.markdown("""
|
|
89 |
display: flex;
|
90 |
align-items: center;
|
91 |
gap: 0.5em;
|
92 |
-
flex-wrap: nowrap;
|
93 |
}
|
94 |
.chat-input-bar input {
|
95 |
flex-grow: 1;
|
@@ -208,13 +207,16 @@ if st.session_state.get("is_thinking", False):
|
|
208 |
|
209 |
st.markdown('</div>', unsafe_allow_html=True)
|
210 |
|
211 |
-
# --- Input bar (
|
212 |
-
st.
|
213 |
-
|
214 |
-
user_input =
|
215 |
-
|
216 |
-
|
217 |
-
st.markdown('</div>', unsafe_allow_html=True)
|
|
|
|
|
|
|
218 |
|
219 |
# --- Auto-scroll JS ---
|
220 |
st.markdown("""
|
@@ -231,7 +233,7 @@ setTimeout(function(){
|
|
231 |
""", unsafe_allow_html=True)
|
232 |
|
233 |
# --- Handle user input ---
|
234 |
-
if user_input:
|
235 |
st.session_state["is_thinking"] = True
|
236 |
thread_id = get_or_create_thread_id()
|
237 |
client.beta.threads.messages.create(thread_id=thread_id, role="user", content=user_input)
|
|
|
63 |
display: flex;
|
64 |
flex-direction: column;
|
65 |
justify-content: flex-end;
|
66 |
+
height: calc(100vh - 230px);
|
67 |
+
margin-bottom: 6em;
|
68 |
}
|
69 |
.chat-history-wrapper {
|
70 |
flex-grow: 1;
|
|
|
89 |
display: flex;
|
90 |
align-items: center;
|
91 |
gap: 0.5em;
|
|
|
92 |
}
|
93 |
.chat-input-bar input {
|
94 |
flex-grow: 1;
|
|
|
207 |
|
208 |
st.markdown('</div>', unsafe_allow_html=True)
|
209 |
|
210 |
+
# --- Input bar (Streamlit FORM) ---
|
211 |
+
with st.form("chat_form", clear_on_submit=True):
|
212 |
+
st.markdown('<div class="chat-input-bar">', unsafe_allow_html=True)
|
213 |
+
user_input = st.text_input("Type your message here:", label_visibility="collapsed")
|
214 |
+
submit_button = st.form_submit_button("Send")
|
215 |
+
clear_button = st.button("🗑️", help="Clear Chat", key="clear-chat-bottom")
|
216 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
217 |
+
|
218 |
+
if clear_button:
|
219 |
+
clear_chat_history()
|
220 |
|
221 |
# --- Auto-scroll JS ---
|
222 |
st.markdown("""
|
|
|
233 |
""", unsafe_allow_html=True)
|
234 |
|
235 |
# --- Handle user input ---
|
236 |
+
if submit_button and user_input:
|
237 |
st.session_state["is_thinking"] = True
|
238 |
thread_id = get_or_create_thread_id()
|
239 |
client.beta.threads.messages.create(thread_id=thread_id, role="user", content=user_input)
|