aboutsummaryrefslogtreecommitdiff
path: root/comfier.py
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2026-10-17 12:52:42 +0200
committerFelix Morgner <felix.morgner@gmail.com>2026-10-17 12:52:42 +0200
commit5edb6e2fd048f369828984aaae6f7ce83d683201 (patch)
tree50de87735605b4936d0378754c3d51602e8f0c20 /comfier.py
parent3f88638e4d1c380d730274f46bac6670b1c6a35e (diff)
downloadcomfier-5edb6e2fd048f369828984aaae6f7ce83d683201.tar.xz
comfier-5edb6e2fd048f369828984aaae6f7ce83d683201.zip
claude: improved dev-setup
Diffstat (limited to 'comfier.py')
-rw-r--r--comfier.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/comfier.py b/comfier.py
index a97fd0d..33277fb 100644
--- a/comfier.py
+++ b/comfier.py
@@ -8,7 +8,6 @@ version: 0.1.0
license: 3-clause-BSD
"""
-import aiohttp
import asyncio
import copy
import inspect
@@ -17,14 +16,14 @@ import mimetypes
import random
import time
import uuid
-
-from fastapi import Request
-from pydantic import BaseModel, Field
from typing import Annotated, Any, Awaitable, Callable, Optional
+import aiohttp
+from fastapi import Request
from open_webui.models.config import Config
from open_webui.models.users import Users
from open_webui.routers.images import get_image_config, upload_image
+from pydantic import BaseModel, Field
EventEmitter = Callable[[dict[str, Any]], Awaitable[None]]
EventCall = Callable[[dict[str, Any]], Awaitable[Any]]
@@ -286,7 +285,7 @@ class Tools:
status_info = (h_data[prompt_id] or {}).get("status") or {}
if status_info.get("status_str") == "error":
raise RuntimeError(
- "The job was terminated win an error or interruption on the backend."
+ "The job was terminated with an error or interruption on the backend."
)
return True
@@ -378,7 +377,7 @@ class Tools:
if not is_alive:
raise ConnectionError(
f"ComfyUI backend lost prompt {prompt_id} (backend may have restarted or crashed)."
- )
+ ) from None
continue
if msg.type != aiohttp.WSMsgType.TEXT:
@@ -457,7 +456,7 @@ class Tools:
if not output_images:
raise RuntimeError(
- "Generation finished without producing any output. The Job may have beend cancelled or removed from the queue."
+ "Generation finished without producing any output. The Job may have been cancelled or removed from the queue."
)
await self._emit_status(
@@ -486,7 +485,7 @@ class Tools:
or "image/png"
)
- uploaded = upload_image(
+ uploaded: Any = upload_image(
request=request,
image_data=image_bytes,
content_type=content_type,
@@ -502,10 +501,10 @@ class Tools:
if isinstance(uploaded, str):
url = uploaded
- elif hasattr(uploaded, "id"):
- url = f"/api/v1/files/{uploaded.id}/content"
elif isinstance(uploaded, dict) and "id" in uploaded:
url = f"/api/v1/files/{uploaded['id']}/content"
+ elif hasattr(uploaded, "id"):
+ url = f"/api/v1/files/{uploaded.id}/content" # pyright: ignore[reportAttributeAccessIssue]
else:
raise RuntimeError(
f"Unexpected return type from upload_image: {type(uploaded)!r}"
@@ -699,4 +698,3 @@ class Tools:
raw_steps = await Config.get("image_generation.steps", 25)
return int(raw_steps)
-