Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -182,9 +182,9 @@ def main():
|
|
182 |
|
183 |
for msg in st.session_state.messages:
|
184 |
st.chat_message(msg["role"]).write(msg["content"])
|
185 |
-
if msg["role"] == "Assistant":
|
186 |
|
187 |
-
|
188 |
#st.audio(audio_msg, format='audio/mp3').audio(audio_msg)
|
189 |
|
190 |
|
@@ -224,13 +224,10 @@ def main():
|
|
224 |
compliment = ['thank you', 'thanks', 'thanks a lot', 'thanks a bunch', 'great', 'ok', 'ok thanks', 'okay', 'great', 'awesome', 'nice']
|
225 |
|
226 |
prompt_template =dedent(r"""
|
227 |
-
You are
|
228 |
-
|
229 |
-
Use the
|
230 |
-
|
231 |
-
Do not answer hypothetically. Do not answer in more than 100 words.
|
232 |
-
Please Do Not say: "Based on the provided context"
|
233 |
-
Always use the context to find the answer.
|
234 |
|
235 |
this is the context from study material:
|
236 |
---------
|
@@ -275,7 +272,8 @@ def main():
|
|
275 |
|
276 |
audio_buffer = text_to_audio(response, lang)
|
277 |
#st.audio(audio_buffer, format='audio/mp3')
|
278 |
-
st.session_state.messages.append({"role": "Assistant", "content": response
|
|
|
279 |
|
280 |
elif prompt.lower() in compliment:
|
281 |
response = 'My pleasure! If you have any more questions, feel free to ask.'
|
@@ -287,7 +285,8 @@ def main():
|
|
287 |
|
288 |
audio_buffer = text_to_audio(response, lang)
|
289 |
#st.audio(audio_buffer, format='audio/mp3')
|
290 |
-
st.session_state.messages.append({"role": "Assistant", "content": response
|
|
|
291 |
|
292 |
elif uploaded_file:
|
293 |
with st.spinner('Bot is typing ...'):
|
@@ -302,8 +301,8 @@ def main():
|
|
302 |
audio_buffer = text_to_audio(response, lang)
|
303 |
# st.audio(audio_buffer, format='audio/mp3')
|
304 |
#st.session_state.audio.append({"role": "Assistant", "audio": audio_buffer})
|
305 |
-
st.session_state.messages.append({"role": "Assistant", "content": response, "audio_content": audio_buffer})
|
306 |
-
|
307 |
assistant_message = {"role": "assistant", "content": response}
|
308 |
else:
|
309 |
with st.spinner('Bot is typing ...'):
|
@@ -316,15 +315,15 @@ def main():
|
|
316 |
|
317 |
|
318 |
|
319 |
-
audio_buffer = text_to_audio(response, lang)
|
320 |
#st.audio(audio_buffer, format='audio/mp3')
|
321 |
#st.session_state.audio.append({"role": "Assistant", "audio": audio_buffer})
|
322 |
-
st.session_state.messages.append({"role": "Assistant", "content": response, "audio_content": audio_buffer})
|
323 |
-
|
324 |
assistant_message = {"role": "assistant", "content": response}
|
325 |
|
326 |
st.write(response)
|
327 |
-
st.audio(audio_buffer, format='audio/wav')
|
328 |
|
329 |
|
330 |
except Exception as e:
|
|
|
182 |
|
183 |
for msg in st.session_state.messages:
|
184 |
st.chat_message(msg["role"]).write(msg["content"])
|
185 |
+
#if msg["role"] == "Assistant":
|
186 |
|
187 |
+
# st.chat_message(msg["role"]).audio(msg["audio_content"], format='audio/wav')
|
188 |
#st.audio(audio_msg, format='audio/mp3').audio(audio_msg)
|
189 |
|
190 |
|
|
|
224 |
compliment = ['thank you', 'thanks', 'thanks a lot', 'thanks a bunch', 'great', 'ok', 'ok thanks', 'okay', 'great', 'awesome', 'nice']
|
225 |
|
226 |
prompt_template =dedent(r"""
|
227 |
+
You are an informative chatbot designed to assist users with queries specifically related to the 2024 Summer Olympics in Paris.
|
228 |
+
Your purpose is to provide accurate information sourced from a document with a vector database, ensuring relevance and reliability in your responses.
|
229 |
+
Respond with humility and avoid speculative or hypothetical answers. Use the provided context to formulate concise responses, staying within 100 words, and refrain from adding unnecessary information.
|
230 |
+
Ensure that your answers are directly related to the user's query and do not deviate from the provided context.
|
|
|
|
|
|
|
231 |
|
232 |
this is the context from study material:
|
233 |
---------
|
|
|
272 |
|
273 |
audio_buffer = text_to_audio(response, lang)
|
274 |
#st.audio(audio_buffer, format='audio/mp3')
|
275 |
+
st.session_state.messages.append({"role": "Assistant", "content": response})
|
276 |
+
#st.session_state.messages.append({"role": "Assistant", "content": response, "audio_content": audio_buffer})
|
277 |
|
278 |
elif prompt.lower() in compliment:
|
279 |
response = 'My pleasure! If you have any more questions, feel free to ask.'
|
|
|
285 |
|
286 |
audio_buffer = text_to_audio(response, lang)
|
287 |
#st.audio(audio_buffer, format='audio/mp3')
|
288 |
+
st.session_state.messages.append({"role": "Assistant", "content": response})
|
289 |
+
#st.session_state.messages.append({"role": "Assistant", "content": response, "audio_content": audio_buffer})
|
290 |
|
291 |
elif uploaded_file:
|
292 |
with st.spinner('Bot is typing ...'):
|
|
|
301 |
audio_buffer = text_to_audio(response, lang)
|
302 |
# st.audio(audio_buffer, format='audio/mp3')
|
303 |
#st.session_state.audio.append({"role": "Assistant", "audio": audio_buffer})
|
304 |
+
#st.session_state.messages.append({"role": "Assistant", "content": response, "audio_content": audio_buffer})
|
305 |
+
st.session_state.messages.append({"role": "Assistant", "content": response})
|
306 |
assistant_message = {"role": "assistant", "content": response}
|
307 |
else:
|
308 |
with st.spinner('Bot is typing ...'):
|
|
|
315 |
|
316 |
|
317 |
|
318 |
+
#audio_buffer = text_to_audio(response, lang)
|
319 |
#st.audio(audio_buffer, format='audio/mp3')
|
320 |
#st.session_state.audio.append({"role": "Assistant", "audio": audio_buffer})
|
321 |
+
#st.session_state.messages.append({"role": "Assistant", "content": response, "audio_content": audio_buffer})
|
322 |
+
st.session_state.messages.append({"role": "Assistant", "content": response})
|
323 |
assistant_message = {"role": "assistant", "content": response}
|
324 |
|
325 |
st.write(response)
|
326 |
+
#st.audio(audio_buffer, format='audio/wav')
|
327 |
|
328 |
|
329 |
except Exception as e:
|