-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_model.py
More file actions
35 lines (29 loc) · 1012 Bytes
/
Copy pathtest_model.py
File metadata and controls
35 lines (29 loc) · 1012 Bytes
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
"""
Simple Model Test
Test if the model works with a basic request
"""
import google.generativeai as genai
import os
from dotenv import load_dotenv
load_dotenv()
# Configure API
api_key = os.getenv("GEMINI_API_KEY")
print(f"API Key loaded: {api_key[:10]}...")
genai.configure(api_key=api_key)
print("\n" + "=" * 70)
print("Testing models/gemini-1.5-flash")
print("=" * 70)
try:
model = genai.GenerativeModel("models/gemini-1.5-flash")
resp = model.generate_content("Say hello!")
print(f"✅ Success! Response: {resp.text}")
except Exception as e:
print(f"❌ Error with models/gemini-1.5-flash: {e}")
print("\nTrying gemini-1.5-flash without 'models/' prefix...")
try:
model = genai.GenerativeModel("gemini-1.5-flash")
resp = model.generate_content("Say hello!")
print(f"✅ Success! Response: {resp.text}")
print("\n⚠️ Note: Use 'gemini-1.5-flash' (without 'models/' prefix)")
except Exception as e2:
print(f"❌ Also failed: {e2}")