This commit is contained in:
puke
2025-10-25 19:39:13 +08:00
committed by puke
parent fe6fa4923e
commit 60918f69b1
55 changed files with 13552 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
"""
Image Generation Service
"""
from typing import Optional
from reelforge.services.base import BaseService
class ImageService(BaseService):
"""
Image generation service
Provides unified access to various image generation providers (ComfyKit, etc.)
Returns path or URL to generated image.
Usage:
# Direct call with workflow path
image_path = await reelforge.image(
workflow="workflows/book_cover.json",
title="Atomic Habits",
author="James Clear"
)
# Returns: "http://comfyui.local/view?filename=..."
# Or use workflow ID (if using RunningHub)
image_path = await reelforge.image(
workflow="12345",
prompt="a beautiful landscape"
)
# Check active image generator
print(f"Using: {reelforge.image.active}")
"""
def __init__(self, router):
super().__init__(router, "image")
async def __call__(
self,
workflow: str,
**params
) -> str:
"""
Generate image using workflow
Args:
workflow: Workflow path, ID, or URL
**params: Workflow parameters (e.g., prompt, title, author, etc.)
Returns:
Image URL or path (str)
Example:
# Generate book cover
image_url = await reelforge.image(
workflow="workflows/book_cover.json",
title="Atomic Habits",
author="James Clear",
genre="Self-Help"
)
# Generate from text prompt
image_url = await reelforge.image(
workflow="workflows/text2img.json",
prompt="a cute cat playing with yarn",
width=1024,
height=768
)
"""
call_params = {"workflow": workflow}
call_params.update(params)
return await self._config_manager.call(self._capability_type, **call_params)