HNTAI / services /ai-service /tests /debug_gemini.py
sachinchandrankallar's picture
Introduce AI medical extraction service with new API, agents, comprehensive testing, and documentation, while reorganizing existing scripts.
d7f1bb5
Raw
History Blame
778 Bytes
import os
import google.generativeai as genai
api_key = os.getenv("GOOGLE_API_KEY")
if not api_key:
print("Error: GOOGLE_API_KEY not set")
exit(1)
print(f"Checking models for key ending in ...{api_key[-4:]}")
genai.configure(api_key=api_key)
try:
print("Listing available models...")
for m in genai.list_models():
if 'generateContent' in m.supported_generation_methods:
print(f"- {m.name}")
except Exception as e:
print(f"Error listing models: {e}")
try:
print("\nAttempting generation with 'gemini-1.5-flash'...")
model = genai.GenerativeModel('gemini-1.5-flash')
response = model.generate_content("Hello")
print(f"Success! Response: {response.text}")
except Exception as e:
print(f"Test generation failed: {e}")