|
|
|
|
|
""" |
|
|
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 = [ |
|
|
{ |
|
|
"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']}'") |
|
|
|
|
|
|
|
|
emotion, confidence = detect_emotion(test_case['input']) |
|
|
emoji = get_emoji(emotion, confidence) |
|
|
print(f"Emotion: {emotion} ({confidence:.2f}) β {emoji}") |
|
|
|
|
|
|
|
|
try: |
|
|
response = respond(test_case['input'], [], max_length=80, temperature=0.7) |
|
|
print(f"Response: '{response}'") |
|
|
|
|
|
|
|
|
if len(response) > 20 and len(response) < 200: |
|
|
print("β
Good response length") |
|
|
else: |
|
|
print(f"β οΈ Response length: {len(response)} chars") |
|
|
|
|
|
|
|
|
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") |
|
|
|
|
|
|
|
|
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() |
|
|
|