Spaces:
Sleeping
Sleeping
File size: 1,332 Bytes
76c6f71 |
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 |
"""
Quick test to verify Anthropic API connection
"""
import sys
from pathlib import Path
# Add src to path
sys.path.insert(0, str(Path(__file__).parent.parent))
from src.llm.anthropic_client import AnthropicClient
print("\n" + "=" * 70)
print("Testing Anthropic API Connection")
print("=" * 70 + "\n")
try:
# Initialize client
print("1. Initializing Anthropic client...")
client = AnthropicClient()
print(f" ✓ Client initialized")
print(f" Model: {client.model}")
print(f" Max tokens: {client.max_tokens}")
print(f" Temperature: {client.temperature}")
# Test connection
print("\n2. Testing API connection...")
if client.test_connection():
print(" ✓ API connection successful!")
else:
print(" ✗ API connection failed")
exit(1)
# Test a simple query
print("\n3. Testing a simple query...")
response = client.generate_response(
system_prompt="You are a helpful assistant. Be brief.",
user_message="Say 'Hello from the AI Personas system!' and nothing else.",
max_tokens=50,
)
print(f" Response: {response}")
print("\n" + "=" * 70)
print("✓ All API tests passed! System is ready to use.")
print("=" * 70 + "\n")
except Exception as e:
print(f"\n✗ Error: {e}\n")
exit(1)
|