Spaces:
Sleeping
Sleeping
| """ | |
| 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) | |