expandme commited on
Commit
973c2a9
·
1 Parent(s): 20dff35

response was disapeering!

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -109,5 +109,15 @@ if prompt := st.chat_input(f"Hi I'm {selected_model}, How can I help you today?"
109
  stream=True
110
  )
111
 
112
- response = st.write_stream(output)
113
- st.session_state.messages.append({"role": "assistant", "content": response})
 
 
 
 
 
 
 
 
 
 
 
109
  stream=True
110
  )
111
 
112
+ # Create a placeholder for the streaming response
113
+ message_placeholder = st.empty()
114
+ full_response = ""
115
+
116
+ # Stream the response and accumulate it
117
+ for chunk in output:
118
+ full_response += chunk
119
+ message_placeholder.markdown(full_response + "▌")
120
+
121
+ # Display final response and store it
122
+ message_placeholder.markdown(full_response)
123
+ st.session_state.messages.append({"role": "assistant", "content": full_response})