latheefahmed03 commited on
Commit
24b8a77
·
verified ·
1 Parent(s): a5a152d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -9,10 +9,10 @@ def load_data():
9
 
10
  data = load_data()
11
 
12
- # Load NLP model for intent detection using DeepSeek
13
  @st.cache_resource
14
  def load_nlp_model():
15
- return pipeline("zero-shot-classification", model="deepseek-ai/deepseek-llm-7b-chat")
16
 
17
  classifier = load_nlp_model()
18
 
@@ -21,16 +21,17 @@ 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
-
28
- # Check if DeepSeek returns results properly
29
- if "labels" in result:
30
- intent = result["labels"][0] # Get the most likely intent
 
 
31
  else:
32
- st.write("Intent detection failed. Please try again.")
33
- intent = None
34
 
35
  if intent == "coverage explanation":
36
  st.subheader("Coverage Details")
 
9
 
10
  data = load_data()
11
 
12
+ # Load DeepSeek model (General text classification)
13
  @st.cache_resource
14
  def load_nlp_model():
15
+ return pipeline("text-classification", model="deepseek-ai/deepseek-llm-7b-chat")
16
 
17
  classifier = load_nlp_model()
18
 
 
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 using text classification
25
+ result = classifier(user_input)
26
+ label = result[0]["label"] # Get predicted label
27
+
28
+ # Manual mapping (since DeepSeek does not support `candidate_labels`)
29
+ if "coverage" in user_input.lower():
30
+ intent = "coverage explanation"
31
+ elif "recommend" in user_input.lower() or "best plan" in user_input.lower():
32
+ intent = "plan recommendation"
33
  else:
34
+ intent = "unknown"
 
35
 
36
  if intent == "coverage explanation":
37
  st.subheader("Coverage Details")