-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_models.py
More file actions
49 lines (42 loc) · 1.5 KB
/
debug_models.py
File metadata and controls
49 lines (42 loc) · 1.5 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 vertexai
from vertexai.preview.generative_models import GenerativeModel
import os
PROJECT_ID = "alloydbtest-374215"
REGION = "us-central1"
print(f"Initializing Vertex AI for {PROJECT_ID} in {REGION}...")
vertexai.init(project=PROJECT_ID, location=REGION)
from google.cloud import aiplatform
aiplatform.init(project=PROJECT_ID, location=REGION)
print("Listing Publisher Models (GenAI)...")
try:
# There isn't a direct "list_generative_models" in the high level SDK easily,
# but we can try to instantiate a few known ones and check errors,
# OR use the Model Garden API if available.
# A better check is to try to list models via the API.
# Actually, let's just try to run them one by one and print the EXACT error.
models = [
"gemini-1.5-flash-001",
"gemini-1.5-flash-002",
"gemini-1.5-flash",
"gemini-1.5-pro-001",
"gemini-1.5-pro-002",
"gemini-1.5-pro",
"gemini-1.0-pro-001",
"gemini-1.0-pro-002",
"gemini-1.0-pro",
"gemini-pro",
"text-bison@001",
"text-bison@002"
]
for m in models:
print(f"Testing {m}...")
try:
model = GenerativeModel(m)
response = model.generate_content("Hello, can you hear me?")
print(f"SUCCESS: {m}")
print(f"Response: {response.text}")
break # Found one!
except Exception as e:
print(f"FAIL: {m} - {e}")
except Exception as e:
print(f"Global Error: {e}")