Update app.py
Browse files
app.py
CHANGED
|
@@ -196,23 +196,24 @@ IMPORTANT NOTES:
|
|
| 196 |
|
| 197 |
# Update is_medical_query to be more comprehensive
|
| 198 |
def is_medical_query(query):
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
|
|
|
|
| 216 |
# Update chat_with_model to enforce medical-only responses
|
| 217 |
def chat_with_model(message, history):
|
| 218 |
try:
|
|
|
|
| 196 |
|
| 197 |
# Update is_medical_query to be more comprehensive
|
| 198 |
def is_medical_query(query):
|
| 199 |
+
medical_keywords_and_greetings = [
|
| 200 |
+
"health", "disease", "symptom", "doctor", "medicine", "medical", "treatment",
|
| 201 |
+
"hospital", "clinic", "diagnosis", "patient", "drug", "prescription", "therapy",
|
| 202 |
+
"cancer", "diabetes", "heart", "blood", "pain", "surgery", "vaccine", "infection",
|
| 203 |
+
"allergy", "diet", "nutrition", "vitamin", "exercise", "mental health", "depression",
|
| 204 |
+
"anxiety", "disorder", "syndrome", "chronic", "acute", "emergency", "pharmacy",
|
| 205 |
+
"dosage", "side effect", "contraindication", "body", "organ", "immune", "virus",
|
| 206 |
+
"bacterial", "fungal", "parasite", "genetic", "hereditary", "congenital", "prenatal",
|
| 207 |
+
"headaches", "ache", "stomach ache", "skin", "head", "arm", "leg", "chest", "back", "throat", "eye", "ear", "nose", "mouth"
|
| 208 |
+
]
|
| 209 |
+
|
| 210 |
+
# Remove greetings from the keyword list
|
| 211 |
+
medical_keywords = [word for word in medical_keywords_and_greetings if word not in ["hello", "hi", "greetings", "good morning", "good afternoon", "good evening", "hey"]]
|
| 212 |
+
|
| 213 |
+
query_lower = query.lower()
|
| 214 |
+
return any(keyword in query_lower for keyword in medical_keywords)
|
| 215 |
|
| 216 |
+
|
| 217 |
# Update chat_with_model to enforce medical-only responses
|
| 218 |
def chat_with_model(message, history):
|
| 219 |
try:
|