feat: Added the ComfyUI engine (#12)
#11 Added the complete ComfyUI engine. Co-authored-by: Sayan Datta <sayan@Sayans-MacBook-Air.local> Reviewed-on: #12
This commit was merged in pull request #12.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Dream Weaver API Gateway v2 — Dynamic Keyword → Local LLM → ComfyUI Pipeline
|
||||
========================================================================
|
||||
@@ -15,7 +15,7 @@ Environment variables:
|
||||
OLLAMA_URL — Ollama server (default: http://localhost:11434)
|
||||
OLLAMA_MODEL — Model name (default: qwen3.5:27b)
|
||||
"""
|
||||
import asyncio, json, time, uuid, io, sys, os, logging
|
||||
import asyncio, json, time, uuid, io, sys, os, logging, traceback
|
||||
from pathlib import Path
|
||||
from typing import Optional, List
|
||||
|
||||
@@ -31,7 +31,7 @@ SCRIPTS_DIR = Path(__file__).parent / "scripts"
|
||||
sys.path.insert(0, str(SCRIPTS_DIR))
|
||||
|
||||
try:
|
||||
from prompt_expander import expand_prompt, expand_prompt_simple, ROOM_CONTEXTS, ExpandedPrompt
|
||||
from prompt_expander import expand_prompt, ROOM_CONTEXTS, ExpandedPrompt
|
||||
LLM_AVAILABLE = True
|
||||
except ImportError:
|
||||
LLM_AVAILABLE = False
|
||||
@@ -40,7 +40,7 @@ except ImportError:
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
||||
logger = logging.getLogger("DreamWeaverGateway")
|
||||
|
||||
COMFY = "http://127.0.0.1:8188"
|
||||
COMFY = "http://127.0.0.1:8118"
|
||||
COMFY_ROOT = "/opt/dlami/nvme/ComfyUI"
|
||||
|
||||
app = FastAPI(
|
||||
@@ -210,7 +210,7 @@ async def expand_endpoint(req: ExpandRequest):
|
||||
additional_notes=req.additional_notes
|
||||
)
|
||||
else:
|
||||
result = expand_prompt_simple(req.keywords, req.room_type)
|
||||
raise RuntimeError("Local LLM model is not available or disabled.")
|
||||
except Exception as e:
|
||||
logger.error(f"Prompt expansion failed: {e}")
|
||||
raise HTTPException(status_code=500, detail=f"LLM expansion failed: {str(e)}")
|
||||
@@ -291,7 +291,7 @@ async def dream_weaver(
|
||||
additional_notes=additional_notes
|
||||
)
|
||||
else:
|
||||
expanded = expand_prompt_simple(kw_list, room_type)
|
||||
raise HTTPException(status_code=500, detail="LLM model is not available or disabled.")
|
||||
|
||||
# Apply manual overrides if provided
|
||||
if denoise > 0:
|
||||
@@ -335,6 +335,7 @@ async def dream_weaver(
|
||||
except Exception as e:
|
||||
jobs[job_id] = {"status": "error", "error": str(e)}
|
||||
logger.error(f"Generation failed: {e}")
|
||||
traceback.print_exc()
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@@ -396,8 +397,10 @@ async def dream_weaver_sync(
|
||||
expanded = _P()
|
||||
elif keywords:
|
||||
kw_list = [k.strip() for k in keywords.split(",") if k.strip()]
|
||||
expanded = (expand_prompt(kw_list, room_type, additional_notes)
|
||||
if LLM_AVAILABLE else expand_prompt_simple(kw_list, room_type))
|
||||
if LLM_AVAILABLE:
|
||||
expanded = expand_prompt(kw_list, room_type, additional_notes)
|
||||
else:
|
||||
raise RuntimeError("Local LLM model is not available or disabled.")
|
||||
else:
|
||||
raise HTTPException(status_code=400, detail="Provide keywords or custom_positive")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user