Spaces:
Sleeping
Sleeping
Update streamlit_app.py
Browse files- streamlit_app.py +14 -7
streamlit_app.py
CHANGED
|
@@ -98,16 +98,23 @@ if question and st.session_state.query_count < 50:
|
|
| 98 |
with response_col:
|
| 99 |
st.markdown("### 🤖 Assistant Response")
|
| 100 |
|
| 101 |
-
#
|
| 102 |
response_placeholder = st.empty()
|
| 103 |
-
|
| 104 |
-
#
|
| 105 |
start_time = time.time()
|
| 106 |
-
|
| 107 |
-
#
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
response_time = time.time() - start_time
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
|
| 113 |
with debug_col:
|
|
|
|
| 98 |
with response_col:
|
| 99 |
st.markdown("### 🤖 Assistant Response")
|
| 100 |
|
| 101 |
+
# live placeholder for streaming text
|
| 102 |
response_placeholder = st.empty()
|
| 103 |
+
|
| 104 |
+
# timing
|
| 105 |
start_time = time.time()
|
| 106 |
+
|
| 107 |
+
# Reset accumulated text and attach placeholder to the handler
|
| 108 |
+
st.session_state.bot.stream_handler.current_text = ""
|
| 109 |
+
st.session_state.bot.stream_handler.placeholder = response_placeholder
|
| 110 |
+
|
| 111 |
+
# Call ask normally (no extra keyword arg)
|
| 112 |
+
answer = st.session_state.bot.ask(question)
|
| 113 |
+
|
| 114 |
response_time = time.time() - start_time
|
| 115 |
+
|
| 116 |
+
# Ensure final result is displayed without cursor
|
| 117 |
+
response_placeholder.markdown(answer)
|
| 118 |
|
| 119 |
|
| 120 |
with debug_col:
|