Update main.py
Browse files
main.py
CHANGED
|
@@ -47,19 +47,20 @@ try:
|
|
| 47 |
if not gemini_api_key: raise ValueError("The 'Gemini' environment variable for the API key is not set.")
|
| 48 |
|
| 49 |
# --- CORRECTED SDK PATTERN, AS PER OFFICIAL DOCUMENTATION ---
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
| 53 |
# --- END OF CORRECTION ---
|
| 54 |
|
| 55 |
-
logger.info("Google GenAI Client initialized successfully using the correct
|
| 56 |
|
| 57 |
ELEVENLABS_API_KEY = os.environ.get("ELEVENLABS_API_KEY")
|
| 58 |
if not ELEVENLABS_API_KEY: raise ValueError("The 'ELEVENLABS_API_KEY' environment variable is not set.")
|
| 59 |
logger.info("ElevenLabs API Key loaded.")
|
| 60 |
except Exception as e:
|
| 61 |
logger.critical(f"FATAL: Error initializing AI Clients: {e}")
|
| 62 |
-
logger.critical(traceback.format_exc())
|
| 63 |
exit(1)
|
| 64 |
|
| 65 |
|
|
|
|
| 47 |
if not gemini_api_key: raise ValueError("The 'Gemini' environment variable for the API key is not set.")
|
| 48 |
|
| 49 |
# --- CORRECTED SDK PATTERN, AS PER OFFICIAL DOCUMENTATION ---
|
| 50 |
+
# 1. Configure the API key at the module level.
|
| 51 |
+
genai.configure(api_key=gemini_api_key)
|
| 52 |
+
# 2. Create the model instance directly from the genai module.
|
| 53 |
+
gemini_model = genai.GenerativeModel(model_name='gemini-2.0-flash')
|
| 54 |
# --- END OF CORRECTION ---
|
| 55 |
|
| 56 |
+
logger.info("Google GenAI Client initialized successfully using the correct GenerativeModel pattern.")
|
| 57 |
|
| 58 |
ELEVENLABS_API_KEY = os.environ.get("ELEVENLABS_API_KEY")
|
| 59 |
if not ELEVENLABS_API_KEY: raise ValueError("The 'ELEVENLABS_API_KEY' environment variable is not set.")
|
| 60 |
logger.info("ElevenLabs API Key loaded.")
|
| 61 |
except Exception as e:
|
| 62 |
logger.critical(f"FATAL: Error initializing AI Clients: {e}")
|
| 63 |
+
logger.critical(traceback.format_exc())
|
| 64 |
exit(1)
|
| 65 |
|
| 66 |
|