Logeswaransr commited on
Commit
618df11
·
verified ·
1 Parent(s): 2797abc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Created on Sun Oct 01 10:49:43 2023
3
+ @author: Loges
4
+ """
5
+
6
+ import streamlit as st
7
+ import sentencepiece
8
+ from interaction import generate_response, audio_response
9
+
10
+ st.set_page_config(page_title='AI Chaperone - RAG', layout='wide')
11
+
12
+ if 'messages' not in st.session_state:
13
+ st.session_state.messages=[]
14
+
15
+
16
+ st.subheader("AI Chaperone")
17
+
18
+ for message in st.session_state.messages:
19
+ with st.chat_message(message['role']):
20
+ st.markdown(message['content'])
21
+
22
+ if prompt:=st.chat_input("Enter your query"):
23
+ with st.chat_message("user"):
24
+ st.markdown(prompt)
25
+
26
+ st.session_state.messages.append({
27
+ 'role':'user',
28
+ 'content': prompt})
29
+
30
+ response=generate_response(prompt, st.session_state.messages)
31
+ with st.chat_message("assistant"):
32
+ st.markdown(response)
33
+
34
+ audio_tag = audio_response(response)
35
+
36
+ st.markdown(audio_tag, unsafe_allow_html=True)
37
+
38
+ st.session_state.messages.append({
39
+ 'role':'assistant',
40
+ 'content': response})