-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_other_models.py
More file actions
117 lines (101 loc) · 3.16 KB
/
test_other_models.py
File metadata and controls
117 lines (101 loc) · 3.16 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env python3
"""
Test script to check which models are available with your API keys.
Supports: OpenAI GPT, Anthropic Claude, Grok
"""
import os
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# ===============================
# OpenAI GPT Test
# ===============================
def test_openai_models():
import openai
openai_api_key = os.getenv("OPENAI_API_KEY")
model_names = [
"gpt-4o",
"gpt-4o-mini",
"gpt-4-turbo",
"gpt-3.5-turbo"
]
if not openai_api_key:
print("❌ OPENAI_API_KEY not found in .env")
return
openai.api_key = openai_api_key
print("\n🤖 Testing OpenAI GPT models...")
for model in model_names:
try:
response = openai.chat.completions.create(
model=model,
messages=[{"role": "user", "content": "Say 'Model working correctly.'"}],
temperature=0
)
output = response.choices[0].message.content.strip()
print(f"✅ {model}: Working | Response: {output}")
except Exception as e:
print(f"❌ {model}: {e}")
# ===============================
# Anthropic Claude Test
# ===============================
def test_claude_models():
import anthropic
api_key = os.getenv("ANTHROPIC_API_KEY")
model_names = [
"claude-3",
"claude-3-100k",
"claude-3-sonnet-20240229"
]
if not api_key:
print("❌ ANTHROPIC_API_KEY not found in .env")
return
client = anthropic.Anthropic(api_key=api_key)
print("\n🤖 Testing Anthropic Claude models...")
for model in model_names:
try:
response = client.completions.create(
model=model,
prompt="Say 'Model working correctly.'",
max_tokens_to_sample=20
)
output = response.completion.strip()
print(f"✅ {model}: Working | Response: {output}")
except Exception as e:
print(f"❌ {model}: {e}")
# ===============================
# Grok / Groq Test
# ===============================
def test_grok_models():
from groq import Groq
api_key = os.getenv("GROQ_API_KEY")
model_names = [
"grok-4-latest",
"grok-3.5",
"grok-3-latest",
"grok-4-fast-reasoning"
]
if not api_key:
print("❌ GROQ_API_KEY not found in .env")
return
client = Groq(api_key=api_key)
print("\n🤖 Testing Grok models...")
for model in model_names:
try:
completion = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": "Say 'Model working correctly.'"}]
)
output = completion.choices[0].message.content.strip()
print(f"✅ {model}: Working | Response: {output}")
except Exception as e:
print(f"❌ {model}: {e}")
# ===============================
# Main
# ===============================
if __name__ == "__main__":
print("="*50)
print("🎯 Model Connectivity Test")
print("="*50)
test_openai_models()
test_claude_models()
test_grok_models()