Solshine commited on
Commit
134de35
1 Parent(s): ed720e5

Update app.py

Browse files

Moved:
message = {"role": "assistant", "content": response}
st.session_state.messages.append(message)
from 109 to 121

Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -106,19 +106,20 @@ def launch_bot():
106
  # st.write("Mistral:" ) #Needs finishing
107
  # else:
108
  st.write(response)
109
- message = {"role": "assistant", "content": response}
110
- st.session_state.messages.append(message)
111
 
112
  # If assistant has most recently reaponded create audio of response
113
  # if st.session_state.messages[-1]["role"] == "assistant":
114
  audio_result = st.button("Convert to Audio 🔊")
115
  if audio_result:
116
- # with st.chat_message("assistant"):
117
- st.write("Converting text to speech. This may take a few minutes.")
118
  sound_file = BytesIO()
119
  tts = gTTS('Add text-to-speech to your app', lang='en')
120
  tts.write_to_fp(sound_file)
121
  st.audio(sound_file)
 
 
 
122
 
123
  if __name__ == "__main__":
124
  launch_bot()
 
106
  # st.write("Mistral:" ) #Needs finishing
107
  # else:
108
  st.write(response)
 
 
109
 
110
  # If assistant has most recently reaponded create audio of response
111
  # if st.session_state.messages[-1]["role"] == "assistant":
112
  audio_result = st.button("Convert to Audio 🔊")
113
  if audio_result:
114
+ with st.chat_message("assistant"):
115
+ st.write("Converting text to speech. This may take a few minutes.")
116
  sound_file = BytesIO()
117
  tts = gTTS('Add text-to-speech to your app', lang='en')
118
  tts.write_to_fp(sound_file)
119
  st.audio(sound_file)
120
+
121
+ message = {"role": "assistant", "content": response}
122
+ st.session_state.messages.append(message)
123
 
124
  if __name__ == "__main__":
125
  launch_bot()