#!/usr/bin/env python3 """ Test Conversational Voice Bot Features Demonstrates how the bot now asks for clarification like your friend's bot """ import asyncio import logging # Setup logging logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') logger = logging.getLogger(__name__) async def test_conversational_features(): """Test the conversational clarity detection""" print("๐ŸŽฏ Testing Conversational Voice Bot Features") print("=" * 60) print("This demonstrates how your bot now asks for clarification") print("just like your friend's superior voice bot!") print() try: from conversational_service import conversational_service # Test queries that should trigger clarification test_cases = [ { "query": "pension", "description": "Vague pension query", "expected": "Should ask for specific pension topic" }, { "query": "what", "description": "Too generic query", "expected": "Should ask what topic user wants help with" }, { "query": "help", "description": "General help request", "expected": "Should provide topic options" }, { "query": "tender", "description": "Vague procurement query", "expected": "Should ask about specific procurement aspect" }, { "query": "What are the pension rules?", "description": "Clear specific query", "expected": "Should proceed with search (no clarification needed)" } ] for i, test_case in enumerate(test_cases, 1): print(f"๐Ÿ” Test {i}: {test_case['description']}") print(f"Query: \"{test_case['query']}\"") print(f"Expected: {test_case['expected']}") print("-" * 50) # Analyze query clarity clarity_analysis = conversational_service.analyze_query_clarity( test_case['query'], [] # Empty search results for testing ) if clarity_analysis['clarification_needed']: print("โœ… RESULT: Bot will ask for clarification") print("๐Ÿค– Bot response:") print() for question in clarity_analysis['clarification_questions']: print(f" {question}") print() if 'suggested_responses' in clarity_analysis: for suggestion in clarity_analysis['suggested_responses']: print(f" {suggestion}") else: print("โœ… RESULT: Query is clear, will proceed with search") print(f"๐ŸŽฏ Confidence: {clarity_analysis['confidence']:.2f}") print() print("=" * 60) print() except ImportError as e: print(f"โŒ Import error: {e}") print("๐Ÿ’ก Make sure you're running from the PensionBot directory") except Exception as e: print(f"โŒ Test error: {e}") def demonstrate_conversation_flow(): """Demonstrate a full conversation flow""" print("๐Ÿ’ฌ Conversation Flow Demonstration") print("=" * 40) print("Here's how a conversation now works:") print() conversation = [ {"speaker": "๐Ÿ‘ค User", "message": "pension"}, {"speaker": "๐Ÿค– Bot", "message": """I can help with pension-related questions! To give you the most accurate information, could you specify: ๐Ÿ“‹ What specifically about pension? โ€ข How to calculate pension amount? โ€ข Pension eligibility criteria? โ€ข How to apply for pension? โ€ข Family pension benefits? โ€ข Commutation of pension? Please let me know which aspect interests you most!"""}, {"speaker": "๐Ÿ‘ค User", "message": "calculation"}, {"speaker": "๐Ÿค– Bot", "message": """Here's the pension calculation formula: **Formula**: (Last drawn basic pay + DA) ร— service years รท 70 **Minimum pension**: โ‚น9,000 per month **Maximum pension**: No upper limit **Example calculation**: - Last basic pay: โ‚น50,000 - DA: โ‚น25,000 (50% of basic) - Service years: 30 - Pension = (50,000 + 25,000) ร— 30 รท 70 = โ‚น32,143 per month Would you like me to help with a specific pension calculation for your situation?"""} ] for exchange in conversation: print(f"{exchange['speaker']}: {exchange['message']}") print() print("๐ŸŽฏ Key Improvements:") print("โœ… Bot asks for clarification instead of guessing") print("โœ… Provides structured options for user to choose") print("โœ… Follows up with specific, detailed information") print("โœ… Encourages further conversation") print() print("This is exactly how your friend's bot works! ๐ŸŽ‰") if __name__ == "__main__": print("๐ŸŽฏ Conversational Voice Bot Test") print("Testing enhanced conversational features") print() # Run the tests asyncio.run(test_conversational_features()) print("\n" + "="*60) demonstrate_conversation_flow()