Spaces:
Sleeping
Sleeping
fix(genai): handle API key errors gracefully
Browse files
services/genai_service.py
CHANGED
|
@@ -18,13 +18,10 @@ def configure_genai():
|
|
| 18 |
|
| 19 |
try:
|
| 20 |
genai.configure(api_key=api_key)
|
| 21 |
-
|
| 22 |
-
# Testa se a chave está funcionando
|
| 23 |
model = genai.GenerativeModel("gemini-1.5-flash")
|
| 24 |
-
model.start_chat().send_message("ping")
|
| 25 |
-
|
| 26 |
print("✅ Chave da API configurada com sucesso.")
|
| 27 |
return model
|
| 28 |
|
| 29 |
except Exception as e:
|
| 30 |
-
|
|
|
|
|
|
| 18 |
|
| 19 |
try:
|
| 20 |
genai.configure(api_key=api_key)
|
|
|
|
|
|
|
| 21 |
model = genai.GenerativeModel("gemini-1.5-flash")
|
|
|
|
|
|
|
| 22 |
print("✅ Chave da API configurada com sucesso.")
|
| 23 |
return model
|
| 24 |
|
| 25 |
except Exception as e:
|
| 26 |
+
print(f"❌ Falha ao configurar a chave da API: {e}")
|
| 27 |
+
return None
|