KrSharangrav commited on
Commit
3a2e6c2
·
1 Parent(s): a610a88

change in UI

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -10,20 +10,23 @@ insert_data_if_empty()
10
  collection = get_mongo_client()
11
 
12
  st.subheader("💬 Chatbot with Sentiment Analysis & Category Extraction")
13
- # Updated hint to include examples for basic questions and entry queries.
14
- user_prompt = st.text_area(
15
- "Ask me something (e.g., 'Provide analysis for data entry 1 in the dataset' or 'What is the dataset summary?'):"
16
- )
 
 
 
 
17
 
18
  if st.button("Get Response"):
19
  ai_response, sentiment_label, sentiment_confidence, topic_label, topic_confidence = chatbot_response(user_prompt)
20
  if ai_response:
21
  st.write("### Response:")
22
- st.write(ai_response)
23
  st.write("### Sentiment Analysis:")
24
- # Convert sentiment confidence to percentage format (e.g., 70% confidence)
25
- st.write(f"**Sentiment Detected:** {sentiment_label} ({sentiment_confidence * 100:.0f}% confidence)")
26
  st.write("### Category Extraction:")
27
- st.write(f"**Category Detected:** {topic_label} ({topic_confidence * 100:.0f}% confidence)")
28
  else:
29
  st.warning("⚠️ Please enter a question or text for analysis.")
 
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("Example Questions"):
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.")