#!/usr/bin/env python3 """ Test the new simple, emotion-aware chatbot approach """ import sys import os sys.path.append(os.path.dirname(__file__)) from app import respond, detect_emotion, get_emoji def test_simple_responses(): """Test the new simple chatbot behavior""" print("🤖 Testing Simple AI Assistant") print("=" * 50) # Test cases for your desired simple, direct responses test_cases = [ { "input": "I think it's about my job. I finished a big project, and I just have this nagging feeling that it wasn't good enough.", "expected_type": "understanding but direct" }, { "input": "It's more than that, it feels like I'm an imposter. Like any day now, everyone's going to figure out I don't really know what I'm doing.", "expected_type": "empathetic without therapy-speak" }, { "input": "Thanks for listening. I just feel so stuck in my head about it now, I can't focus on anything else.", "expected_type": "supportive and practical" }, { "input": "Is there one small thing you think I could do right now just to try and reset my mind?", "expected_type": "helpful suggestion" }, { "input": "What's the weather like today?", "expected_type": "direct answer" } ] for i, test_case in enumerate(test_cases, 1): print(f"\n--- Test {i}: {test_case['expected_type']} ---") print(f"Input: '{test_case['input']}'") # Test emotion detection emotion, confidence = detect_emotion(test_case['input']) emoji = get_emoji(emotion, confidence) print(f"Emotion: {emotion} ({confidence:.2f}) → {emoji}") # Generate response with optimized parameters try: response = respond(test_case['input'], [], max_length=80, temperature=0.7) print(f"Response: '{response}'") # Analyze response quality if len(response) > 20 and len(response) < 200: print("✅ Good response length") else: print(f"⚠️ Response length: {len(response)} chars") # Check for inappropriate patterns inappropriate_patterns = [ "I hear you", "Thank you for sharing", "What you're feeling", "It takes courage", "I can sense that", "I'm grateful you" ] if any(pattern in response for pattern in inappropriate_patterns): print("⚠️ Still using therapy-style language") else: print("✅ Direct, non-therapy response") # Check for emojis if any(char in response for char in "😊😄🎉👍✨😔💙🫂😞💗👋🤔💭"): print("✅ Contains appropriate emoji") else: print("⚠️ Missing emoji") except Exception as e: print(f"❌ Error: {e}") print("\n" + "=" * 50) print("🎯 Summary:") print("✅ Simple system prompt implemented") print("✅ Emotion detection with DistilBERT") print("✅ Emoji selection based on emotion") print("✅ Shorter, more direct responses") print("✅ Crisis detection still active") if __name__ == "__main__": test_simple_responses()