|
|
import os |
|
|
from pathlib import Path |
|
|
from dotenv import load_dotenv |
|
|
import google.generativeai as genai |
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
script_dir = Path(__file__).resolve().parent |
|
|
|
|
|
project_root = script_dir.parent.parent |
|
|
dotenv_path = project_root / "configs" / ".env" |
|
|
|
|
|
if dotenv_path.exists(): |
|
|
load_dotenv(dotenv_path=dotenv_path) |
|
|
print(f"β
Environment variables loaded from: {dotenv_path}") |
|
|
else: |
|
|
print(f"β οΈ Warning: .env file not found at {dotenv_path}.") |
|
|
|
|
|
except Exception as e: |
|
|
print(f"Could not load .env file: {e}") |
|
|
|
|
|
|
|
|
api_key = os.getenv("GEMINI_API_KEY") |
|
|
if api_key: |
|
|
try: |
|
|
|
|
|
|
|
|
client = genai.Client() |
|
|
|
|
|
print("\nβ
Available models for 'generateContent':") |
|
|
|
|
|
for m in client.models.list(): |
|
|
if 'generateContent' in m.supported_generation_methods: |
|
|
print(f"- {m.name}") |
|
|
|
|
|
except Exception as e: |
|
|
print(f"π΄ An error occurred while listing models: {e}") |
|
|
print("π‘ Tip: Make sure your API key is correct and has the right permissions.") |
|
|
else: |
|
|
print("π΄ Error: GEMINI_API_KEY not found. Please check your .env file.") |