|
""" |
|
Created on Sun Oct 01 10:49:43 2023 |
|
@author: Loges |
|
""" |
|
|
|
import streamlit as st |
|
import sentencepiece |
|
from interaction import generate_response, audio_response |
|
|
|
st.set_page_config(page_title='AI Chaperone - Chatbot', layout='wide') |
|
|
|
if 'messages' not in st.session_state: |
|
st.session_state.messages=[] |
|
|
|
|
|
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, st.session_state.messages) |
|
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}) |
|
|