File size: 3,469 Bytes
01d262c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
#!/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()
|