File size: 1,050 Bytes
618df11
 
 
 
 
 
 
dc46cad
bcf8056
 
618df11
 
 
 
61a1532
 
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
"""
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=[]

pipeline = init_pipeline()
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})