Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
# Load the dataset
|
6 |
+
@st.cache_data
|
7 |
+
def load_data():
|
8 |
+
return pd.read_csv("insurance_data.csv")
|
9 |
+
|
10 |
+
data = load_data()
|
11 |
+
|
12 |
+
# Load NLP model for intent detection
|
13 |
+
@st.cache_resource
|
14 |
+
def load_nlp_model():
|
15 |
+
return pipeline("text-classification", model="facebook/bart-large-mnli")
|
16 |
+
|
17 |
+
classifier = load_nlp_model()
|
18 |
+
|
19 |
+
# Streamlit UI
|
20 |
+
st.title("Health Insurance Coverage Assistant")
|
21 |
+
user_input = st.text_input("Enter your query (e.g., coverage for diabetes, best plans, etc.)")
|
22 |
+
|
23 |
+
if user_input:
|
24 |
+
# Detect intent
|
25 |
+
labels = ["coverage explanation", "plan recommendation"]
|
26 |
+
result = classifier(user_input, candidate_labels=labels)
|
27 |
+
intent = result["labels"][0] # Get the most likely intent
|
28 |
+
|
29 |
+
if intent == "coverage explanation":
|
30 |
+
st.subheader("Coverage Details")
|
31 |
+
condition_matches = data[data["Medical Condition"].str.contains(user_input, case=False, na=False)]
|
32 |
+
if not condition_matches.empty:
|
33 |
+
st.write(condition_matches)
|
34 |
+
else:
|
35 |
+
st.write("No specific coverage found for this condition.")
|
36 |
+
|
37 |
+
elif intent == "plan recommendation":
|
38 |
+
st.subheader("Recommended Plans")
|
39 |
+
recommended_plans = data.sort_values(by=["Coverage (%)"], ascending=False).head(5)
|
40 |
+
st.write(recommended_plans)
|
41 |
+
|
42 |
+
else:
|
43 |
+
st.write("Sorry, I couldn't understand your request. Please try again!")
|