Spaces:
Sleeping
Sleeping
KrSharangrav
commited on
Commit
Β·
f453bef
1
Parent(s):
117ee2b
adding image in code
Browse files
app.py
CHANGED
@@ -9,24 +9,32 @@ insert_data_if_empty()
|
|
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 |
-
st.write("
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Connect to MongoDB (optional: for additional visualizations)
|
10 |
collection = get_mongo_client()
|
11 |
|
12 |
+
# Create a two-column layout: left for the image, right for the chatbot UI.
|
13 |
+
col1, col2 = st.columns([1, 3])
|
14 |
+
|
15 |
+
with col1:
|
16 |
+
st.image("https://huggingface.co/spaces/sharangrav24/SentimentAnalysis/resolve/main/sentiment.png", use_column_width=True)
|
17 |
+
|
18 |
+
with col2:
|
19 |
+
st.subheader("π¬ Chatbot with Sentiment Analysis & Category Extraction")
|
20 |
+
|
21 |
+
# Create an expander to display example questions on separate lines.
|
22 |
+
with st.expander("π Hi, allow me to help you with prompts:"):
|
23 |
+
st.write("π‘ Provide analysis for data entry 1 in the dataset")
|
24 |
+
st.write("π‘ What is the dataset summary?")
|
25 |
+
st.write("π‘ or just ask me something of your own, I'll be happy to help π")
|
26 |
+
|
27 |
+
# Text area for user input.
|
28 |
+
user_prompt = st.text_area("Ask me something:")
|
29 |
+
|
30 |
+
if st.button("Get Response"):
|
31 |
+
ai_response, sentiment_label, sentiment_confidence, topic_label, topic_confidence = chatbot_response(user_prompt)
|
32 |
+
if ai_response:
|
33 |
+
st.write("### Response:")
|
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.")
|