v2.2 — ComfyUI Portrait Generation
Features:
- 🖼️ Portrait Button im Chat-Header
- /api/comfyui/status: Prüft ob ComfyUI läuft
- /api/character/{name}/portrait: Generiert Profilbild via ComfyUI
- comfyui_integration.py: ComfyUI API Client
- NoobAI-XL Checkpoint
- 25 Steps, DPM++ 2M Karras
- 512x512 Portrait
- Auto-Copy zu static/avatars/
- UI: Avatar wird nach Generierung ersetzt
- UI: Button zeigt Status (ComfyUI nicht erreichbar = ausgegraut)
- Workflow: Character-Beschreibung → ComfyUI Prompt → Bild → Avatar
Voraussetzung: ComfyUI muss auf localhost:8188 laufen
This commit is contained in:
@@ -15,6 +15,8 @@ from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from pydantic import BaseModel
|
||||
|
||||
from comfyui_integration import is_comfyui_running, generate_portrait
|
||||
|
||||
# === Konfiguration ===
|
||||
BASE_DIR = Path(__file__).parent
|
||||
CHARACTERS_DIR = BASE_DIR / "characters"
|
||||
@@ -493,6 +495,30 @@ async def api_list_models():
|
||||
except:
|
||||
return JSONResponse({"models": [], "error": "Ollama nicht erreichbar"})
|
||||
|
||||
@app.get("/api/comfyui/status")
|
||||
async def api_comfyui_status():
|
||||
return JSONResponse({"running": is_comfyui_running()})
|
||||
|
||||
@app.post("/api/character/{name}/portrait")
|
||||
async def api_generate_portrait(name: str, request: Request):
|
||||
"""Generiert ein Profilbild via ComfyUI."""
|
||||
char = load_character(name)
|
||||
|
||||
if not is_comfyui_running():
|
||||
return JSONResponse({"error": "ComfyUI läuft nicht. Starte ComfyUI zuerst."}, status_code=503)
|
||||
|
||||
body = await request.json() if request.headers.get("content-type") == "application/json" else {}
|
||||
custom_prompt = body.get("prompt", "")
|
||||
|
||||
# Build description from character data
|
||||
desc = custom_prompt or f"{char.get('personality', '')}, {char.get('background', '')}"
|
||||
|
||||
image_path = generate_portrait(name, desc)
|
||||
if image_path:
|
||||
return JSONResponse({"status": "ok", "image": image_path})
|
||||
else:
|
||||
return JSONResponse({"error": "Bildgenerierung fehlgeschlagen"}, status_code=500)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
uvicorn.run(app, host="0.0.0.0", port=5252)
|
||||
Reference in New Issue
Block a user