Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import pandas as pd | |
| from transformers import pipeline | |
| # Load the dataset | |
| def load_data(): | |
| return pd.read_csv("insurance_data.csv") | |
| data = load_data() | |
| # Load NLP model for intent detection | |
| def load_nlp_model(): | |
| return pipeline("text-classification", model="facebook/bart-large-mnli") | |
| 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 | |
| labels = ["coverage explanation", "plan recommendation"] | |
| result = classifier(user_input, candidate_labels=labels) | |
| intent = result["labels"][0] # Get the most likely intent | |
| 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!") | |