Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -43,20 +43,27 @@ except Exception as e:
|
|
| 43 |
|
| 44 |
# --- AI Client Initialization ---
|
| 45 |
try:
|
| 46 |
-
gemini_api_key = os.environ.get("Gemini")
|
| 47 |
-
if not gemini_api_key:
|
|
|
|
| 48 |
client = genai.Client(api_key=gemini_api_key)
|
| 49 |
-
MODEL_NAME = 'gemini-2.0-flash'
|
| 50 |
logger.info(f"Google GenAI Client initialized successfully for model {MODEL_NAME}.")
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
except Exception as e:
|
| 55 |
logger.critical(f"FATAL: Error initializing AI Clients: {e}")
|
| 56 |
logger.critical(traceback.format_exc())
|
| 57 |
exit(1)
|
| 58 |
|
| 59 |
|
|
|
|
| 60 |
# -----------------------------------------------------------------------------
|
| 61 |
# 2. CORE HELPER FUNCTIONS
|
| 62 |
# -----------------------------------------------------------------------------
|
|
|
|
| 43 |
|
| 44 |
# --- AI Client Initialization ---
|
| 45 |
try:
|
| 46 |
+
gemini_api_key = (os.environ.get("Gemini") or "").strip()
|
| 47 |
+
if not gemini_api_key:
|
| 48 |
+
raise ValueError("The 'Gemini' environment variable for the API key is not set.")
|
| 49 |
client = genai.Client(api_key=gemini_api_key)
|
| 50 |
+
MODEL_NAME = 'gemini-2.0-flash'
|
| 51 |
logger.info(f"Google GenAI Client initialized successfully for model {MODEL_NAME}.")
|
| 52 |
+
|
| 53 |
+
ELEVENLABS_API_KEY = (os.environ.get("ELEVENLABS_API_KEY") or "").strip()
|
| 54 |
+
if not ELEVENLABS_API_KEY:
|
| 55 |
+
raise ValueError("The 'ELEVENLABS_API_KEY' environment variable is not set.")
|
| 56 |
+
ELEVENLABS_AGENT_ID = (os.environ.get("ELEVENLABS_AGENT_ID") or "").strip()
|
| 57 |
+
if not ELEVENLABS_AGENT_ID:
|
| 58 |
+
raise ValueError("The 'ELEVENLABS_AGENT_ID' environment variable is not set.")
|
| 59 |
+
logger.info("ElevenLabs API Key and Agent ID 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 |
|
| 66 |
+
|
| 67 |
# -----------------------------------------------------------------------------
|
| 68 |
# 2. CORE HELPER FUNCTIONS
|
| 69 |
# -----------------------------------------------------------------------------
|