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 DeepSeek model (General text classification) | |
| 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!") | |