Spaces:
Sleeping
Sleeping
| """Test LLM client initialization""" | |
| import sys | |
| import os | |
| from pathlib import Path | |
| from dotenv import load_dotenv | |
| # Load environment variables | |
| load_dotenv() | |
| # Add src to path | |
| current_dir = Path(__file__).parent.resolve() | |
| sys.path.insert(0, str(current_dir / "src")) | |
| print("=" * 60) | |
| print("Testing LLM Client Initialization") | |
| print("=" * 60) | |
| print(f"\n1. Environment Check:") | |
| print(f" - Current directory: {current_dir}") | |
| print(f" - .env file exists: {(current_dir / '.env').exists()}") | |
| api_key = os.getenv("ANTHROPIC_API_KEY") | |
| print(f" - ANTHROPIC_API_KEY present: {bool(api_key)}") | |
| if api_key: | |
| print(f" - API key length: {len(api_key)} chars") | |
| print(f" - API key starts with: {api_key[:10]}...") | |
| print(f" - API key format valid: {api_key.startswith('sk-ant-')}") | |
| print(f"\n2. Importing AnthropicClient...") | |
| try: | |
| from src.llm.anthropic_client import AnthropicClient | |
| print(" β Import successful") | |
| except Exception as e: | |
| print(f" β Import failed: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| sys.exit(1) | |
| print(f"\n3. Initializing AnthropicClient...") | |
| try: | |
| client = AnthropicClient() | |
| print(" β Initialization successful") | |
| print(f" - Model: {client.model}") | |
| print(f" - Max tokens: {client.max_tokens}") | |
| print(f" - Temperature: {client.temperature}") | |
| except Exception as e: | |
| print(f" β Initialization failed: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| sys.exit(1) | |
| print(f"\n4. Testing connection...") | |
| try: | |
| result = client.test_connection() | |
| if result: | |
| print(" β Connection test successful") | |
| else: | |
| print(" β οΈ Connection test returned False") | |
| except Exception as e: | |
| print(f" β Connection test failed: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| print("\n" + "=" * 60) | |
| print("All tests passed!") | |
| print("=" * 60) | |