iSushant commited on
Commit
d93a1e7
·
verified ·
1 Parent(s): 911b78b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -27
app.py CHANGED
@@ -1,27 +1,23 @@
1
- import pandas as pd
2
- import pickle as pk
3
- from sklearn.feature_extraction.text import TfidfVectorizer
4
- import streamlit as st
5
-
6
- model = pk.load(open('model.pkl','rb'))
7
- scaler = pk.load(open('scaler.pkl','rb'))
8
- review = st.text_input('Tell Us What You Think! Your feedback helps us improve.')
9
-
10
- if st.button('Let me think!'):
11
- review_scale = scaler.transform([review]).toarray()
12
- result = model.predict(review_scale)
13
- if result[0] == 0:
14
- st.write("Thanks for your honest feedback! We are always striving to improve. While your experience wasn't perfect, your insights help us make things better. Would you like to chat with our friendly AI assistant and share some suggestions?")
15
-
16
-
17
- else:
18
- st.write("We're thrilled to hear you had a positive experience! Your feedback motivates us to keep building something great. How about taking your interaction a step further and exploring our AI assistant to see what innovative things we can do together?")
19
-
20
-
21
- if st.button('AI Pal'):
22
-
23
-
24
- chatbot_link = "https://your_chatbot_url" # Replace with your actual chatbot URL
25
- st.button("Hey! My Friendo", on_click=lambda: st.sidebar.open(chatbot_link))
26
-
27
-
 
1
+ import pandas as pd
2
+ import pickle as pk
3
+ import streamlit as st
4
+
5
+ # Load model and scaler
6
+ model = pk.load(open('model.pkl', 'rb'))
7
+ scaler = pk.load(open('scaler.pkl', 'rb'))
8
+
9
+ # Streamlit user input
10
+ review = st.text_input('Tell Us What You Think! Your feedback helps us improve.')
11
+
12
+ if st.button('Let me think!'):
13
+ if review: # Ensure review is not empty
14
+ review_scale = scaler.transform([review]).toarray()
15
+ result = model.predict(review_scale)
16
+ if result[0] == 0:
17
+ st.write("Thanks for your honest feedback! We are always striving to improve. While your experience wasn't perfect, your insights help us make things better. Would you like to chat with our friendly AI assistant and share some suggestions?")
18
+ else:
19
+ st.write("We're thrilled to hear you had a positive experience! Your feedback motivates us to keep building something great. How about taking your interaction a step further and exploring our AI assistant to see what innovative things we can do together?")
20
+
21
+ if st.button('AI Pal'):
22
+ chatbot_link = "https://your_chatbot_url" # Replace with your actual chatbot URL
23
+ st.write(f"Click [here]({chatbot_link}) to chat with our AI assistant.")