File size: 1,876 Bytes
4fcd971
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""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)