-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug_llm.py
More file actions
43 lines (37 loc) Β· 1.41 KB
/
debug_llm.py
File metadata and controls
43 lines (37 loc) Β· 1.41 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
import os
import google.generativeai as genai
from dotenv import load_dotenv
def test_gemini():
load_dotenv()
api_key = os.getenv("GOOGLE_API_KEY")
if not api_key:
print("β GOOGLE_API_KEY not found in environment.")
return
genai.configure(api_key=api_key)
print("Checking available models...")
try:
seen = False
for m in genai.list_models():
if 'generateContent' in m.supported_generation_methods:
print(f"- {m.name}")
seen = True
if not seen:
print("β οΈ No models found with 'generateContent' capability.")
except Exception as e:
print(f"β Error listing models: {e}")
print("\nTesting Generation with 'gemini-3.0-flash'...")
try:
model = genai.GenerativeModel('gemini-3.0-flash')
response = model.generate_content("Hello, are you working?")
print(f"β
Response: {response.text}")
except Exception as e:
print(f"β Failed 'gemini-3.0-flash': {e}")
print("\nTesting Generation with 'models/gemini-3.0-flash' (explicit prefix)...")
try:
model = genai.GenerativeModel('models/gemini-3.0-flash')
response = model.generate_content("Hello, are you working?")
print(f"β
Response: {response.text}")
except Exception as e:
print(f"β Failed 'models/gemini-3.0-flash': {e}")
if __name__ == "__main__":
test_gemini()