a digital person for bluesky
at main 6.8 kB view raw
1#!/usr/bin/env python3 2""" 3Configuration validation test script for Void Bot. 4Run this to verify your config.yaml setup is working correctly. 5""" 6 7 8def test_config_loading(): 9 """Test that configuration can be loaded successfully.""" 10 try: 11 from config_loader import ( 12 get_config, 13 get_letta_config, 14 get_bluesky_config, 15 get_bot_config, 16 get_agent_config, 17 get_threading_config, 18 get_queue_config 19 ) 20 21 print("🔧 Testing Configuration...") 22 print("=" * 50) 23 24 # Test basic config loading 25 config = get_config() 26 print("✅ Configuration file loaded successfully") 27 28 # Test individual config sections 29 print("\n📋 Configuration Sections:") 30 print("-" * 30) 31 32 # Letta Configuration 33 try: 34 letta_config = get_letta_config() 35 print( 36 f"✅ Letta API: project_id={letta_config.get('project_id', 'N/A')[:20]}...") 37 print(f" - Timeout: {letta_config.get('timeout')}s") 38 api_key = letta_config.get('api_key', 'Not configured') 39 if api_key != 'Not configured': 40 print(f" - API Key: ***{api_key[-8:]} (configured)") 41 else: 42 print(" - API Key: ❌ Not configured (required)") 43 except Exception as e: 44 print(f"❌ Letta config: {e}") 45 46 # Bluesky Configuration 47 try: 48 bluesky_config = get_bluesky_config() 49 username = bluesky_config.get('username', 'Not configured') 50 password = bluesky_config.get('password', 'Not configured') 51 pds_uri = bluesky_config.get('pds_uri', 'Not configured') 52 53 if username != 'Not configured': 54 print(f"✅ Bluesky: username={username}") 55 else: 56 print("❌ Bluesky username: Not configured (required)") 57 58 if password != 'Not configured': 59 print(f" - Password: ***{password[-4:]} (configured)") 60 else: 61 print(" - Password: ❌ Not configured (required)") 62 63 print(f" - PDS URI: {pds_uri}") 64 except Exception as e: 65 print(f"❌ Bluesky config: {e}") 66 67 # Bot Configuration 68 try: 69 bot_config = get_bot_config() 70 print(f"✅ Bot behavior:") 71 print( 72 f" - Notification delay: {bot_config.get('fetch_notifications_delay')}s") 73 print( 74 f" - Max notifications: {bot_config.get('max_processed_notifications')}") 75 print( 76 f" - Max pages: {bot_config.get('max_notification_pages')}") 77 except Exception as e: 78 print(f"❌ Bot config: {e}") 79 80 # Agent Configuration 81 try: 82 agent_config = get_agent_config() 83 print(f"✅ Agent settings:") 84 print(f" - Name: {agent_config.get('name')}") 85 print(f" - Model: {agent_config.get('model')}") 86 print(f" - Embedding: {agent_config.get('embedding')}") 87 print(f" - Max steps: {agent_config.get('max_steps')}") 88 blocks = agent_config.get('blocks', {}) 89 print(f" - Memory blocks: {len(blocks)} configured") 90 except Exception as e: 91 print(f"❌ Agent config: {e}") 92 93 # Threading Configuration 94 try: 95 threading_config = get_threading_config() 96 print(f"✅ Threading:") 97 print( 98 f" - Parent height: {threading_config.get('parent_height')}") 99 print(f" - Depth: {threading_config.get('depth')}") 100 print( 101 f" - Max chars/post: {threading_config.get('max_post_characters')}") 102 except Exception as e: 103 print(f"❌ Threading config: {e}") 104 105 # Queue Configuration 106 try: 107 queue_config = get_queue_config() 108 priority_users = queue_config.get('priority_users', []) 109 print(f"✅ Queue settings:") 110 print( 111 f" - Priority users: {len(priority_users)} ({', '.join(priority_users[:3])}{'...' if len(priority_users) > 3 else ''})") 112 print(f" - Base dir: {queue_config.get('base_dir')}") 113 print(f" - Error dir: {queue_config.get('error_dir')}") 114 except Exception as e: 115 print(f"❌ Queue config: {e}") 116 117 print("\n" + "=" * 50) 118 print("✅ Configuration test completed!") 119 120 # Check for common issues 121 print("\n🔍 Configuration Status:") 122 has_letta_key = False 123 has_bluesky_creds = False 124 125 try: 126 letta_config = get_letta_config() 127 has_letta_key = True 128 except: 129 print("⚠️ Missing Letta API key - bot cannot connect to Letta") 130 131 try: 132 bluesky_config = get_bluesky_config() 133 has_bluesky_creds = True 134 except: 135 print("⚠️ Missing Bluesky credentials - bot cannot connect to Bluesky") 136 137 if has_letta_key and has_bluesky_creds: 138 print("🎉 All required credentials configured - bot should work!") 139 elif not has_letta_key and not has_bluesky_creds: 140 print("❌ Missing both Letta and Bluesky credentials") 141 print(" Add them to config.yaml or set environment variables") 142 else: 143 print("⚠️ Partial configuration - some features may not work") 144 145 print("\n📖 Next steps:") 146 if not has_letta_key: 147 print(" - Add your Letta API key to config.yaml under letta.api_key") 148 print(" - Or set LETTA_API_KEY environment variable") 149 if not has_bluesky_creds: 150 print( 151 " - Add your Bluesky credentials to config.yaml under bluesky section") 152 print(" - Or set BSKY_USERNAME and BSKY_PASSWORD environment variables") 153 if has_letta_key and has_bluesky_creds: 154 print(" - Run: python bsky.py") 155 print(" - Or run with testing mode: python bsky.py --test") 156 157 except FileNotFoundError as e: 158 print("❌ Configuration file not found!") 159 print(f" {e}") 160 print("\n📋 To set up configuration:") 161 print(" 1. Copy config.yaml.example to config.yaml") 162 print(" 2. Edit config.yaml with your credentials") 163 print(" 3. Run this test again") 164 except Exception as e: 165 print(f"❌ Configuration loading failed: {e}") 166 print("\n🔧 Troubleshooting:") 167 print(" - Check that config.yaml has valid YAML syntax") 168 print(" - Ensure required fields are not commented out") 169 print(" - See CONFIG.md for detailed setup instructions") 170 171 172if __name__ == "__main__": 173 test_config_loading()