-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_models.py
More file actions
35 lines (27 loc) · 1.11 KB
/
check_models.py
File metadata and controls
35 lines (27 loc) · 1.11 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
# check_models.py
import google.generativeai as genai
import os
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
print("Attempting to connect to Google AI...")
try:
# Get the API key from your environment
api_key = os.getenv('GOOGLE_API_KEY')
if not api_key:
print("\nERROR: GOOGLE_API_KEY not found in .env file!")
print("Please make sure your .env file is in the 'agriculture-chatbot' root directory.")
else:
# Configure the client library
genai.configure(api_key=api_key)
print("Successfully configured. Fetching available models...")
print("="*30)
# List all available models
for m in genai.list_models():
# Check if the model supports the 'generateContent' method (used for chatbots)
if 'generateContent' in m.supported_generation_methods:
print(f"Model Name: {m.name}")
print("="*30)
print("\nTest complete. Please use one of the model names listed above in your config.py file.")
except Exception as e:
print(f"\nAn error occurred: {e}")