Spaces:
Sleeping
Sleeping
File size: 1,156 Bytes
618df11 dc46cad bcf8056 618df11 f6dc3fa 618df11 dc46cad 618df11 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
"""
Created on Sun Oct 01 10:49:43 2023
@author: Loges
"""
import streamlit as st
import sentencepiece
from interaction import generate_response, audio_response, init_pipeline
from initialize import install
st.set_page_config(page_title='AI Chaperone - RAG', layout='wide')
if 'messages' not in st.session_state:
st.session_state.messages=[]
flag=True
while flag:
try:
pipeline = init_pipeline()
flag=False
except:
install('transformers')
st.subheader("AI Chaperone")
for message in st.session_state.messages:
with st.chat_message(message['role']):
st.markdown(message['content'])
if prompt:=st.chat_input("Enter your query"):
with st.chat_message("user"):
st.markdown(prompt)
st.session_state.messages.append({
'role':'user',
'content': prompt})
response=generate_response(prompt, pipeline)
with st.chat_message("assistant"):
st.markdown(response)
audio_tag = audio_response(response)
st.markdown(audio_tag, unsafe_allow_html=True)
st.session_state.messages.append({
'role':'assistant',
'content': response}) |