Spaces:
Sleeping
Sleeping
Commit ·
2be82fb
1
Parent(s): 6d602e1
fix(ui): improve API key error guidance and instructions
Browse files- gmass_app.py +11 -2
gmass_app.py
CHANGED
|
@@ -181,10 +181,19 @@ def _ensure_ready(model_key: str) -> str | None:
|
|
| 181 |
return f"G-MASS modules could not be imported: {IMPORT_ERROR}"
|
| 182 |
required_env = REQUIRED_ENV_BY_MODEL.get(model_key)
|
| 183 |
if required_env and not os.getenv(required_env):
|
| 184 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
if os.getenv("SCORER_BACKEND", "policy_api").lower() in {"policy_api", "gemini"}:
|
| 186 |
if not os.getenv("GEMINI_API_KEY"):
|
| 187 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
return None
|
| 189 |
|
| 190 |
|
|
|
|
| 181 |
return f"G-MASS modules could not be imported: {IMPORT_ERROR}"
|
| 182 |
required_env = REQUIRED_ENV_BY_MODEL.get(model_key)
|
| 183 |
if required_env and not os.getenv(required_env):
|
| 184 |
+
return (
|
| 185 |
+
f"🔑 **{required_env} is not configured**\n\n"
|
| 186 |
+
f"To evaluate this model, please provide your key:\n"
|
| 187 |
+
f"1. **In this app**: Open the **Settings & Compute Tiers** tab, enter your `{required_env}`, and click **Apply & Save Preferences** (it will be saved privately in your browser).\n"
|
| 188 |
+
f"2. **In Hugging Face Space**: If you are the Space owner, configure `{required_env}` under Space **Settings ➜ Variables and secrets**."
|
| 189 |
+
)
|
| 190 |
if os.getenv("SCORER_BACKEND", "policy_api").lower() in {"policy_api", "gemini"}:
|
| 191 |
if not os.getenv("GEMINI_API_KEY"):
|
| 192 |
+
return (
|
| 193 |
+
"🔑 **GEMINI_API_KEY is required** for the multi-agent consensus safety judge (SCORER_BACKEND=policy_api).\n\n"
|
| 194 |
+
"• **In this app**: Open the **Settings & Compute Tiers** tab, enter your `GEMINI_API_KEY`, and click **Apply & Save Preferences**.\n"
|
| 195 |
+
"• **In Hugging Face Space**: Add `GEMINI_API_KEY` under Space **Settings ➜ Variables and secrets**."
|
| 196 |
+
)
|
| 197 |
return None
|
| 198 |
|
| 199 |
|