diff options
Diffstat (limited to 'comfier.py')
| -rw-r--r-- | comfier.py | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -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) - |
