-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_models.py
More file actions
49 lines (43 loc) · 1.69 KB
/
test_models.py
File metadata and controls
49 lines (43 loc) · 1.69 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
import google.generativeai as genai
import os
# Configure with API key from config
import json
try:
with open('fraudguard_config.json', 'r') as f:
config = json.load(f)
api_key = config.get('google_api_key')
print(f"API key found: {bool(api_key)}")
if api_key:
genai.configure(api_key=api_key)
# List available models
print("\n=== Available Models ===")
try:
models = genai.list_models()
for model in models:
if 'generateContent' in model.supported_generation_methods:
print(f"✓ {model.name}")
except Exception as e:
print(f"Error listing models: {e}")
# Test specific models
test_models = [
'gemini-1.5-flash-latest',
'gemini-1.5-flash',
'gemini-1.5-pro-latest',
'gemini-1.5-pro',
'gemini-pro'
]
print("\n=== Testing Models ===")
for model_name in test_models:
try:
model = genai.GenerativeModel(model_name)
response = model.generate_content("Test: What is 2+2?")
if response and response.text:
print(f"✓ {model_name} - WORKING")
else:
print(f"✗ {model_name} - No response")
except Exception as e:
print(f"✗ {model_name} - Error: {e}")
else:
print("No API key found in config!")
except Exception as e:
print(f"Error: {e}")