#!/usr/bin/env python3 """ Debug tool to test Entry Classifier responses """ import os from dotenv import load_dotenv # Load environment variables load_dotenv() # Only proceed if we have the API key if os.getenv("GEMINI_API_KEY"): from core_classes import GeminiAPI, EntryClassifier, ClinicalBackground def test_message(message): """Test a single message with the Entry Classifier""" # Create API and classifier api = GeminiAPI() classifier = EntryClassifier(api) # Create mock clinical background clinical_bg = ClinicalBackground( patient_id="test", patient_name="John", patient_age="52", active_problems=["Nausea", "Hypokalemia", "Type 2 diabetes"], past_medical_history=[], current_medications=["Amlodipine"], allergies="None", vital_signs_and_measurements=[], laboratory_results=[], assessment_and_plan="", critical_alerts=["Life endangering medical noncompliance"], social_history={}, recent_clinical_events=[] ) print(f"\n๐Ÿ” Testing: '{message}'") try: result = classifier.classify(message, clinical_bg) classification = result.get("V", "unknown") timestamp = result.get("T", "unknown") print(f"๐Ÿ“Š Result: V={classification}, T={timestamp}") # Expected results expected_on = ["exercise", "workout", "fitness", "sport", "training", "rehabilitation", "physical", "activity"] should_be_on = any(keyword in message.lower() for keyword in expected_on) if should_be_on and classification == "on": print("โœ… CORRECT: Lifestyle message properly classified as ON") elif should_be_on and classification != "on": print(f"โŒ ERROR: Lifestyle message incorrectly classified as {classification.upper()}") elif not should_be_on and classification == "off": print("โœ… CORRECT: Non-lifestyle message properly classified as OFF") else: print(f"โ„น๏ธ Classification: {classification.upper()}") except Exception as e: print(f"โŒ Error: {e}") if __name__ == "__main__": print("๐Ÿงช Entry Classifier Debug Tool") print("Testing problematic messages...\n") test_messages = [ "I want to exercise", "Let's do some exercises", "Let's talk about rehabilitation", "Everything is fine let's do exercises", "Which exercises are suitable for me", "I have a headache", "Hello", "I want to exercise but my back hurts" ] for message in test_messages: test_message(message) else: print("โŒ GEMINI_API_KEY not found. Please set up your .env file.")