Spaces:
Runtime error
Runtime error
File size: 1,729 Bytes
3849755 24b8a77 3849755 24b8a77 3849755 24b8a77 a190f0a 24b8a77 a5a152d 24b8a77 3849755 |
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
import streamlit as st
import pandas as pd
from transformers import pipeline
# Load the dataset
@st.cache_data
def load_data():
return pd.read_csv("insurance_data.csv")
data = load_data()
# Load DeepSeek model (General text classification)
@st.cache_resource
def load_nlp_model():
return pipeline("text-classification", model="deepseek-ai/deepseek-llm-7b-chat")
classifier = load_nlp_model()
# Streamlit UI
st.title("Health Insurance Coverage Assistant")
user_input = st.text_input("Enter your query (e.g., coverage for diabetes, best plans, etc.)")
if user_input:
# Detect intent using text classification
result = classifier(user_input) # Now we remove candidate_labels
label = result[0]["label"] # Get predicted label
# Manual mapping (since DeepSeek does not support `candidate_labels`)
if "coverage" in user_input.lower():
intent = "coverage explanation"
elif "recommend" in user_input.lower() or "best plan" in user_input.lower():
intent = "plan recommendation"
else:
intent = "unknown"
if intent == "coverage explanation":
st.subheader("Coverage Details")
condition_matches = data[data["Medical Condition"].str.contains(user_input, case=False, na=False)]
if not condition_matches.empty:
st.write(condition_matches)
else:
st.write("No specific coverage found for this condition.")
elif intent == "plan recommendation":
st.subheader("Recommended Plans")
recommended_plans = data.sort_values(by=["Coverage (%)"], ascending=False).head(5)
st.write(recommended_plans)
else:
st.write("Sorry, I couldn't understand your request. Please try again!")
|