arabic-sign-language-yolo / utils /medical_agent_fallback.py
Mr-HASSAN's picture
Rename medical_agent_fallback.py to utils/medical_agent_fallback.py
b89c1cc verified
from collections import defaultdict
class FallbackMedicalAgent:
def __init__(self):
self.sessions = defaultdict(dict)
self.max_questions = 3
def process_input(self, english_text: str, session_id: str) -> dict:
if session_id not in self.sessions:
self.sessions[session_id] = {'question_count': 0}
session = self.sessions[session_id]
question_count = session['question_count'] + 1
session['question_count'] = question_count
if question_count >= self.max_questions:
response = f"Consultation complete. Symptoms: {english_text}. See a doctor."
state = 'summary'
else:
questions = [
"How long have symptoms lasted?",
"Where exactly is the pain?",
"Any other symptoms?"
]
response = questions[min(question_count - 1, len(questions) - 1)]
state = 'questioning'
return {
'response': response,
'question_count': question_count,
'state': state,
'workflow_used': False
}
def process_doctor_input(self, doctor_text: str) -> str:
return "Please describe your symptoms?"