File size: 1,199 Bytes
0105e3b
f89cec9
7268351
be89ae1
ea4634d
84326e0
7268351
ea4634d
84326e0
f89cec9
f37d2cc
84326e0
 
 
 
 
7268351
3280b9f
5a94c8e
7268351
f89cec9
7268351
 
5a94c8e
f16063a
3280b9f
e94ec88
8d3fcda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import streamlit as st
import pandas as pd
from db import insert_data_if_empty, get_mongo_client
from chatbot import chatbot_response

# 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 Dataset Analysis")
# Updated hint to include examples for basic questions and entry queries.
user_prompt = st.text_area(
    "Ask me something (e.g., 'Provide analysis for data entry 1 in the dataset' or 'What is the dataset summary?'):"
)

if st.button("Get AI Response"):
    ai_response, sentiment_label, sentiment_confidence, topic_label, topic_confidence = chatbot_response(user_prompt)
    if ai_response:
        st.write("### Response:")
        st.write(ai_response)
        st.write("### Sentiment Analysis:")
        st.write(f"**Sentiment:** {sentiment_label} ({sentiment_confidence:.2f} confidence)")
        st.write("### Category Extraction:")
        st.write(f"**Detected Category:** {topic_label} ({topic_confidence:.2f} confidence)")
    else:
        st.warning("⚠️ Please enter a question or text for analysis.")