midrees2806 commited on
Commit
c23cce8
·
verified ·
1 Parent(s): a4acd02

Update rag.py

Browse files
Files changed (1) hide show
  1. rag.py +5 -1
rag.py CHANGED
@@ -85,7 +85,7 @@ def get_best_answer(user_input):
85
  user_input_lower = user_input.lower().strip()
86
 
87
  # 👉 Check if question is about fee
88
- if any(keyword in user_input_lower for keyword in ["fee", "fees", "charges", "semester fee"]):
89
  return (
90
  "💰 For complete and up-to-date fee details for this program, we recommend visiting the official University of Education fee structure page.\n"
91
  "You’ll find comprehensive information regarding tuition, admission charges, and other applicable fees there.\n"
@@ -98,6 +98,10 @@ def get_best_answer(user_input):
98
  best_match_idx = similarities.argmax().item()
99
  best_score = similarities[best_match_idx].item()
100
 
 
 
 
 
101
  if best_score >= 0.65:
102
  original_answer = dataset_answers[best_match_idx]
103
  prompt = f"""As an official assistant for University of Education Lahore, provide a clear response:
 
85
  user_input_lower = user_input.lower().strip()
86
 
87
  # 👉 Check if question is about fee
88
+ if any(keyword in user_input_lower for keyword in ["fee structure", "fees structure", "semester fees", "semester fee"]):
89
  return (
90
  "💰 For complete and up-to-date fee details for this program, we recommend visiting the official University of Education fee structure page.\n"
91
  "You’ll find comprehensive information regarding tuition, admission charges, and other applicable fees there.\n"
 
98
  best_match_idx = similarities.argmax().item()
99
  best_score = similarities[best_match_idx].item()
100
 
101
+ # 3. Save unmatched queries (threshold = 0.65)
102
+ if best_score < 0.65:
103
+ manage_unmatched_queries(user_input)
104
+
105
  if best_score >= 0.65:
106
  original_answer = dataset_answers[best_match_idx]
107
  prompt = f"""As an official assistant for University of Education Lahore, provide a clear response: