import streamlit as st import pandas as pd from db import insert_data_if_empty, get_mongo_client from chatbot import chatbot_response # Sidebar: Display image and title. st.sidebar.image("https://huggingface.co/spaces/sharangrav24/SentimentAnalysis/resolve/main/sen_analysis.png", width=200) st.sidebar.markdown("## Group A Submission - Python") # Sidebar: Add submitted by details. st.sidebar.markdown(""" **Submitted by-** ๐Ÿ“ŒKumar Sharangrav [C] (GMP-21-10) ๐Ÿ“ŒAmit Sanjeev (GMP-21-01) ๐Ÿ“ŒAnoop G Zacharia (GMP-21-03) ๐Ÿ“ŒAnviti Pant (GMP-21-05) """) # Ensure historical data is inserted into MongoDB if not already present. insert_data_if_empty() # Connect to MongoDB (optional: for additional visualizations) collection = get_mongo_client() st.subheader("๐Ÿ’ฌ Chatbot with Sentiment Analysis & Category Extraction") # Create an expander to display example questions on separate lines. with st.expander("๐Ÿ‘‹ Hi, allow me to help you with prompts:"): st.write("๐Ÿ’ก Provide analysis for data entry 1 in the dataset") st.write("๐Ÿ’ก What is the dataset summary?") st.write("๐Ÿ’ก or just ask me something of your own, I'll be happy to help ๐Ÿ˜Š") # Text area for user input. user_prompt = st.text_area("Ask me something:") if st.button("Get Response"): ai_response, sentiment_label, sentiment_confidence, topic_label, topic_confidence = chatbot_response(user_prompt) if ai_response: st.write("### Response:") st.markdown(ai_response) st.write("### Sentiment Analysis:") st.write(f"**Sentiment Detected:** {sentiment_label} ({sentiment_confidence:.2f} confidence)") st.write("### Category Extraction:") st.write(f"**Category Detected:** {topic_label} ({topic_confidence:.2f} confidence)") else: st.warning("โš ๏ธ Please enter a question or text for analysis.")