KrSharangrav commited on
Commit
f453bef
Β·
1 Parent(s): 117ee2b

adding image in code

Browse files
Files changed (1) hide show
  1. app.py +29 -21
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
- st.subheader("πŸ’¬ Chatbot with Sentiment Analysis & Category Extraction")
13
-
14
- # Create an expander to display example questions on separate lines.
15
- with st.expander("πŸ‘‹ Hi, allow me to help you with prompts:"):
16
- st.write("πŸ’‘ Provide analysis for data entry 1 in the dataset")
17
- st.write("πŸ’‘ What is the dataset summary?")
18
-
19
- # Text area for user input.
20
- user_prompt = st.text_area("Ask me something:")
21
-
22
- if st.button("Get Response"):
23
- ai_response, sentiment_label, sentiment_confidence, topic_label, topic_confidence = chatbot_response(user_prompt)
24
- if ai_response:
25
- st.write("### Response:")
26
- st.markdown(ai_response)
27
- st.write("### Sentiment Analysis:")
28
- st.write(f"**Sentiment Detected:** {sentiment_label} ({sentiment_confidence:.2f} confidence)")
29
- st.write("### Category Extraction:")
30
- st.write(f"**Category Detected:** {topic_label} ({topic_confidence:.2f} confidence)")
31
- else:
32
- st.warning("⚠️ Please enter a question or text for analysis.")
 
 
 
 
 
 
 
 
 
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.")