-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_openrouter_integration.py
More file actions
84 lines (64 loc) · 2.34 KB
/
test_openrouter_integration.py
File metadata and controls
84 lines (64 loc) · 2.34 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python3
"""
Test script for OpenRouter integration with Horizon Beta
"""
import os
from langchain_openai import ChatOpenAI
# OpenRouter Configuration
OPENROUTER_API_KEY = os.environ.get("OPENROUTER_API_KEY", "")
OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1"
def test_horizon_beta():
"""Test Horizon Beta via OpenRouter"""
print("🚀 Testing Horizon Beta via OpenRouter...")
try:
# Initialize Horizon Beta
llm = ChatOpenAI(
model="openrouter/horizon-beta",
openai_api_key=OPENROUTER_API_KEY,
openai_api_base=OPENROUTER_BASE_URL,
temperature=0.7
)
# Test message
test_message = "Hello! Can you give me a brief overview of your capabilities?"
print(f"📤 Sending message: {test_message}")
# Get response
response = llm.invoke(test_message)
print(f"📥 Response from Horizon Beta:")
print("=" * 50)
print(response.content)
print("=" * 50)
print("✅ OpenRouter integration successful!")
return True
except Exception as e:
print(f"❌ Error testing OpenRouter: {str(e)}")
return False
def test_model_switching():
"""Test switching between different models"""
print("\n🔄 Testing model switching...")
models = {
"horizon-beta": "openrouter/horizon-beta",
"gpt-4": "openai/gpt-4",
"claude": "anthropic/claude-3-5-sonnet"
}
for model_name, model_id in models.items():
try:
print(f"\n🧪 Testing {model_name}...")
llm = ChatOpenAI(
model=model_id,
openai_api_key=OPENROUTER_API_KEY,
openai_api_base=OPENROUTER_BASE_URL,
temperature=0.7
)
response = llm.invoke("Say hello in one sentence.")
print(f"✅ {model_name}: {response.content}")
except Exception as e:
print(f"❌ {model_name}: {str(e)}")
if __name__ == "__main__":
print("🤖 OpenRouter Integration Test")
print("=" * 50)
# Test Horizon Beta
success = test_horizon_beta()
if success:
# Test other models
test_model_switching()
print("\n🎉 Test completed!")