Spaces:
Sleeping
Sleeping
Update rag.py
Browse files
rag.py
CHANGED
|
@@ -43,17 +43,16 @@ def query_groq_llm(prompt, model_name="llama3-70b-8192"):
|
|
| 43 |
print(f"Error querying Groq API: {e}")
|
| 44 |
return ""
|
| 45 |
|
| 46 |
-
def get_best_answer(user_input):
|
| 47 |
user_input_lower = user_input.lower().strip()
|
| 48 |
|
| 49 |
# π Check if question is about fee
|
| 50 |
if any(keyword in user_input_lower for keyword in ["fee", "fees", "charges", "semester fee"]):
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
|
| 58 |
# π Continue with normal similarity-based logic
|
| 59 |
user_embedding = similarity_model.encode(user_input_lower, convert_to_tensor=True)
|
|
@@ -71,13 +70,13 @@ def get_best_answer(user_input):
|
|
| 71 |
prompt = f"""As an official assistant for University of Education Lahore, provide a helpful response:
|
| 72 |
Include relevant details about university policies.
|
| 73 |
If unsure, direct to official channels.
|
| 74 |
-
|
| 75 |
Question: {user_input}
|
| 76 |
-
|
| 77 |
Official Answer:"""
|
| 78 |
|
| 79 |
llm_response = query_groq_llm(prompt)
|
| 80 |
-
|
| 81 |
if llm_response:
|
| 82 |
for marker in ["Improved Answer:", "Official Answer:"]:
|
| 83 |
if marker in llm_response:
|
|
@@ -90,5 +89,6 @@ def get_best_answer(user_input):
|
|
| 90 |
π +92-42-99262231-33
|
| 91 |
βοΈ info@ue.edu.pk
|
| 92 |
π ue.edu.pk"""
|
| 93 |
-
|
| 94 |
return response
|
|
|
|
|
|
| 43 |
print(f"Error querying Groq API: {e}")
|
| 44 |
return ""
|
| 45 |
|
| 46 |
+
def get_best_answer(user_input):
|
| 47 |
user_input_lower = user_input.lower().strip()
|
| 48 |
|
| 49 |
# π Check if question is about fee
|
| 50 |
if any(keyword in user_input_lower for keyword in ["fee", "fees", "charges", "semester fee"]):
|
| 51 |
+
return (
|
| 52 |
+
"π° For complete and up-to-date fee details for this program, we recommend visiting the official University of Education fee structure page.\n"
|
| 53 |
+
"Youβll find comprehensive information regarding tuition, admission charges, and other applicable fees there.\n"
|
| 54 |
+
"π https://ue.edu.pk/allfeestructure.php"
|
| 55 |
+
)
|
|
|
|
| 56 |
|
| 57 |
# π Continue with normal similarity-based logic
|
| 58 |
user_embedding = similarity_model.encode(user_input_lower, convert_to_tensor=True)
|
|
|
|
| 70 |
prompt = f"""As an official assistant for University of Education Lahore, provide a helpful response:
|
| 71 |
Include relevant details about university policies.
|
| 72 |
If unsure, direct to official channels.
|
| 73 |
+
|
| 74 |
Question: {user_input}
|
| 75 |
+
|
| 76 |
Official Answer:"""
|
| 77 |
|
| 78 |
llm_response = query_groq_llm(prompt)
|
| 79 |
+
|
| 80 |
if llm_response:
|
| 81 |
for marker in ["Improved Answer:", "Official Answer:"]:
|
| 82 |
if marker in llm_response:
|
|
|
|
| 89 |
π +92-42-99262231-33
|
| 90 |
βοΈ info@ue.edu.pk
|
| 91 |
π ue.edu.pk"""
|
| 92 |
+
|
| 93 |
return response
|
| 94 |
+
|