feat: Editable safety settings in SettingsModal
Backend: - New POST /api/image-gen/config endpoint to update image generation config in-memory (applies immediately, resets on server restart) - Accepts: model, safety_harassment, safety_hate_speech, safety_sexually_explicit, safety_dangerous Frontend: - SettingsModal safety filters are now editable dropdowns (no longer disabled) - Model selection is also editable - Added 'Save Changes' button with visual feedback: * Green 'Settings saved!' on success * Red 'Failed to save' on error * Disabled when no changes made - Tracks edited state vs. saved state - Note: changes apply immediately but reset on server restart (set .env for persistence) Fixed TypeScript issues: - getConfigValue() properly typed to return string only - Proper union type for config keys excluding has_api_key
This commit is contained in:
1 parent
6410e16912
commit
a79b2806dc
2 files changed
+81
-14
No files matched your search
@@ -298,6 +298,23 @@ async def get_image_gen_configuration():
|
||||
"has_api_key": bool(config.get("api_key")),
|
||||
}
|
||||
|
||||
@app.post("/api/image-gen/config")
|
||||
async def update_image_gen_configuration(request: dict):
|
||||
"""Update image generation configuration (in-memory only, not persisted to .env)."""
|
||||
# Update environment variables in-memory for this process
|
||||
if "model" in request:
|
||||
os.environ["IMAGE_GEN_MODEL"] = request["model"]
|
||||
if "safety_harassment" in request:
|
||||
os.environ["IMAGE_GEN_SAFETY_HARASSMENT"] = request["safety_harassment"]
|
||||
if "safety_hate_speech" in request:
|
||||
os.environ["IMAGE_GEN_SAFETY_HATE_SPEECH"] = request["safety_hate_speech"]
|
||||
if "safety_sexually_explicit" in request:
|
||||
os.environ["IMAGE_GEN_SAFETY_SEXUALLY_EXPLICIT"] = request["safety_sexually_explicit"]
|
||||
if "safety_dangerous" in request:
|
||||
os.environ["IMAGE_GEN_SAFETY_DANGEROUS"] = request["safety_dangerous"]
|
||||
|
||||
return {"status": "updated"}
|
||||
|
||||
@app.patch("/api/clips/{clip_id}")
|
||||
async def rename_clip_endpoint(clip_id: str, request: RenameRequest):
|
||||
clip = await get_clip(clip_id)
|
||||
|
||||
Reference in new issue
Block a user