Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from config import setup_environment
|
3 |
+
from rag_initializer import initialize_rag_chain
|
4 |
+
from chatbot import chatbot_response
|
5 |
+
|
6 |
+
setup_environment()
|
7 |
+
|
8 |
+
st.set_page_config(page_title="Mini AI Bot for Englishfirm.com", page_icon="🤖", layout="wide")
|
9 |
+
|
10 |
+
def main():
|
11 |
+
st.title("Mini AI Bot for Englishfirm.com")
|
12 |
+
st.sidebar.info("Englishfirm is the one of the best PTE coaching academies in Sydney. Among 52 PTE institutes in Sydney, Englishfirm is the only training centre in Sydney that offers 100% one-on-one coaching. Englishfirm has 2 branches in Sydney, operating 7 day a week. We operate from Sydney CBD campus (Pitt Street) and Parramatta.")
|
13 |
+
st.sidebar.warning("Disclaimer: This chatbot provides information related to Englishfirm's IELTS, PTE, and Spoken English coaching services. While we strive to offer accurate and up-to-date information, this should not be considered a substitute for professional educational advice. For personalized guidance and assistance, please contact our experts directly.")
|
14 |
+
rag_chain = initialize_rag_chain()
|
15 |
+
|
16 |
+
if rag_chain is None:
|
17 |
+
st.error("Failed to initialize the chatbot. Please try again later.")
|
18 |
+
return
|
19 |
+
|
20 |
+
st.write("Welcome to Englishfirm! I'm here to assist you with any questions regarding our IELTS, PTE, and Spoken English coaching. How can I help you today?")
|
21 |
+
if "messages" not in st.session_state:
|
22 |
+
st.session_state.messages = []
|
23 |
+
|
24 |
+
for message in st.session_state.messages:
|
25 |
+
with st.chat_message(message["role"]):
|
26 |
+
st.markdown(message["content"])
|
27 |
+
|
28 |
+
if prompt := st.chat_input("Your question:"):
|
29 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
30 |
+
with st.chat_message("user"):
|
31 |
+
st.markdown(prompt)
|
32 |
+
|
33 |
+
with st.chat_message("assistant"):
|
34 |
+
with st.spinner("AI is thinking..."):
|
35 |
+
response = chatbot_response(prompt, rag_chain)
|
36 |
+
st.markdown(response)
|
37 |
+
|
38 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|
39 |
+
|
40 |
+
|
41 |
+
if __name__ == "__main__":
|
42 |
+
main()
|