ciorant commited on
Commit
b48e7d9
·
verified ·
1 Parent(s): 73a52fa

Update streamlit_app.py

Browse files
Files changed (1) hide show
  1. 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
- # Create a placeholder for the streaming response
102
  response_placeholder = st.empty()
103
-
104
- # Start timing
105
  start_time = time.time()
106
-
107
- # Run the chatbot and let it stream directly into Streamlit
108
- answer = st.session_state.bot.ask(question, stream_placeholder=response_placeholder)
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: