File size: 3,373 Bytes
a4a766c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
93
# debug_env.py - Debug script to check environment setup
import os
from pathlib import Path

def debug_environment():
    """Debug environment variables and .env file"""
    
    print("πŸ” Environment Setup Debug")
    print("=" * 50)
    
    # Check .env file exists
    env_file = Path(".env")
    if env_file.exists():
        print("βœ… .env file found")
        
        # Read and check .env contents
        with open(env_file, 'r') as f:
            env_contents = f.read()
        
        print(f"πŸ“„ .env file contents ({env_file.absolute()}):")
        print("-" * 30)
        
        # Check specific keys
        keys_to_check = [
            "GROQ_API_KEY",
            "ELEVENLABS_API_KEY", 
            "ELEVENLABS_AGENT_ID",
            "ELEVENLABS_PHONE_NUMBER_ID"
        ]
        
        for line in env_contents.split('\n'):
            if line.strip() and not line.startswith('#'):
                key = line.split('=')[0]
                if key in keys_to_check:
                    value = line.split('=', 1)[1] if '=' in line else ''
                    if value and len(value) > 10:
                        print(f"βœ… {key}={value[:10]}...")
                    elif value:
                        print(f"⚠️  {key}={value} (might be incomplete)")
                    else:
                        print(f"❌ {key}= (empty)")
                        
        print("-" * 30)
    else:
        print("❌ .env file not found!")
        print(f"   Expected location: {env_file.absolute()}")
        return
    
    print("\nπŸ”§ Environment Variables (os.getenv):")
    print("-" * 30)
    for key in ["GROQ_API_KEY", "ELEVENLABS_API_KEY", "ELEVENLABS_AGENT_ID", "ELEVENLABS_PHONE_NUMBER_ID"]:
        value = os.getenv(key)
        if value:
            print(f"βœ… {key}: {value[:10]}..." if len(value) > 10 else f"βœ… {key}: {value}")
        else:
            print(f"❌ {key}: Not set")
    
    print("\n🎯 Pydantic Settings Test:")
    print("-" * 30)
    try:
        from config.settings import settings
        
        # Test settings
        checks = [
            ("groq_api_key", settings.groq_api_key),
            ("elevenlabs_api_key", settings.elevenlabs_api_key),
            ("elevenlabs_agent_id", settings.elevenlabs_agent_id),
            ("elevenlabs_phone_number_id", settings.elevenlabs_phone_number_id)
        ]
        
        for name, value in checks:
            if value:
                display_value = value[:10] + "..." if len(str(value)) > 10 else str(value)
                print(f"βœ… settings.{name}: {display_value}")
            else:
                print(f"❌ settings.{name}: None/Empty")
                
    except Exception as e:
        print(f"❌ Settings import failed: {e}")
    
    print("\nπŸ“‹ Setup Instructions:")
    print("-" * 30)
    print("1. Ensure .env file is in the same directory as main.py")
    print("2. Add these lines to your .env file:")
    print("   GROQ_API_KEY=gsk_your_groq_key_here")
    print("   ELEVENLABS_API_KEY=sk_your_elevenlabs_key_here")
    print("   ELEVENLABS_AGENT_ID=your_agent_id_here")
    print("   ELEVENLABS_PHONE_NUMBER_ID=your_phone_id_here")
    print("3. Restart your server: python main.py")
    print("4. Test with: curl http://localhost:8000/api/webhook/test-elevenlabs")

if __name__ == "__main__":
    debug_environment()