Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -57,6 +57,19 @@ except ImportError as e:
|
|
57 |
# Configure logging
|
58 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(module)s - %(message)s')
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
# --- Gradio UI Blocks ---
|
62 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
|
|
|
57 |
# Configure logging
|
58 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(module)s - %(message)s')
|
59 |
|
60 |
+
# 1. Set Vertex AI usage preference (if applicable)
|
61 |
+
os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "False"
|
62 |
+
|
63 |
+
# 2. Get your API key from your chosen environment variable name
|
64 |
+
# Replace "YOUR_GEMINI_API_KEY_ENV_NAME" with the actual name you use, e.g., "GEMINI_API_KEY" or "GOOGLE_API_KEY"
|
65 |
+
user_provided_api_key = os.environ.get("GEMINI_API_KEY")
|
66 |
+
|
67 |
+
if user_provided_api_key:
|
68 |
+
os.environ["GOOGLE_API_KEY"] = user_provided_api_key
|
69 |
+
logging.info("GOOGLE_API_KEY environment variable has been set from YOUR_GEMINI_API_KEY_ENV_NAME.")
|
70 |
+
else:
|
71 |
+
logging.error(f"CRITICAL ERROR: The API key environment variable 'YOUR_GEMINI_API_KEY_ENV_NAME' was not found. The application may not function correctly.")
|
72 |
+
|
73 |
|
74 |
# --- Gradio UI Blocks ---
|
75 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
|