Spaces:
Sleeping
Sleeping
KrSharangrav
commited on
Commit
Β·
f2ddc64
1
Parent(s):
f453bef
change in UI image
Browse files
app.py
CHANGED
|
@@ -3,38 +3,35 @@ import pandas as pd
|
|
| 3 |
from db import insert_data_if_empty, get_mongo_client
|
| 4 |
from chatbot import chatbot_response
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# Ensure historical data is inserted into MongoDB if not already present.
|
| 7 |
insert_data_if_empty()
|
| 8 |
|
| 9 |
# Connect to MongoDB (optional: for additional visualizations)
|
| 10 |
collection = get_mongo_client()
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
with
|
| 16 |
-
st.
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
st.markdown(ai_response)
|
| 35 |
-
st.write("### Sentiment Analysis:")
|
| 36 |
-
st.write(f"**Sentiment Detected:** {sentiment_label} ({sentiment_confidence*100:.2f}% confidence)")
|
| 37 |
-
st.write("### Category Extraction:")
|
| 38 |
-
st.write(f"**Category Detected:** {topic_label} ({topic_confidence*100:.2f}% confidence)")
|
| 39 |
-
else:
|
| 40 |
-
st.warning("β οΈ Please enter a question or text for analysis.")
|
|
|
|
| 3 |
from db import insert_data_if_empty, get_mongo_client
|
| 4 |
from chatbot import chatbot_response
|
| 5 |
|
| 6 |
+
# Sidebar: Display image and title.
|
| 7 |
+
st.sidebar.image("https://huggingface.co/spaces/sharangrav24/SentimentAnalysis/resolve/main/sentiment.png", width=100)
|
| 8 |
+
st.sidebar.markdown("## Group A Submission - Python")
|
| 9 |
+
|
| 10 |
# Ensure historical data is inserted into MongoDB if not already present.
|
| 11 |
insert_data_if_empty()
|
| 12 |
|
| 13 |
# Connect to MongoDB (optional: for additional visualizations)
|
| 14 |
collection = get_mongo_client()
|
| 15 |
|
| 16 |
+
st.subheader("π¬ Chatbot with Sentiment Analysis & Category Extraction")
|
| 17 |
+
|
| 18 |
+
# Create an expander to display example questions on separate lines.
|
| 19 |
+
with st.expander("π Hi, allow me to help you with prompts:"):
|
| 20 |
+
st.write("π‘ Provide analysis for data entry 1 in the dataset")
|
| 21 |
+
st.write("π‘ What is the dataset summary?")
|
| 22 |
+
st.write("π‘ or just ask me something of your own, I'll be happy to help π")
|
| 23 |
+
|
| 24 |
+
# Text area for user input.
|
| 25 |
+
user_prompt = st.text_area("Ask me something:")
|
| 26 |
+
|
| 27 |
+
if st.button("Get Response"):
|
| 28 |
+
ai_response, sentiment_label, sentiment_confidence, topic_label, topic_confidence = chatbot_response(user_prompt)
|
| 29 |
+
if ai_response:
|
| 30 |
+
st.write("### Response:")
|
| 31 |
+
st.markdown(ai_response)
|
| 32 |
+
st.write("### Sentiment Analysis:")
|
| 33 |
+
st.write(f"**Sentiment Detected:** {sentiment_label} ({sentiment_confidence*100:.2f}% confidence)")
|
| 34 |
+
st.write("### Category Extraction:")
|
| 35 |
+
st.write(f"**Category Detected:** {topic_label} ({topic_confidence*100:.2f}% confidence)")
|
| 36 |
+
else:
|
| 37 |
+
st.warning("β οΈ Please enter a question or text for analysis.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|