Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:869413421 Ai moive studio CanvasGenerationService

From Leeroopedia
Knowledge Sources
Domains Generative_AI, Architecture
Last Updated 2026-10-23 12:00 GMT

Overview

Service that processes text, image, and video generation requests on canvas nodes via the GatewayProvider, with SSE streaming and generation history tracking.

Description

CanvasGenerationService (within canvas.py) handles AI generation for canvas nodes:

  • process_text_generation: Calls GatewayProvider.completions with the node's prompt and model; stores result text in the generation record
  • process_image_generation: Calls GatewayProvider.generate_image with prompt, model, aspect ratio, and optional reference images; uploads result to MinIO
  • process_video_generation: Calls GatewayProvider.create_video with prompt, reference images, and options; stores provider_task_id for async polling or directly stores completed video

All methods update the CanvasItemGeneration record with status transitions (processing → completed/failed) and result payloads. Text generation supports SSE streaming via stream_text_generation.

Usage

Import when processing AI generation for canvas nodes. Called by canvas Celery tasks (generate_canvas_text/image/video).

Code Reference

Source Location

Signature

class CanvasGenerationService(BaseService):
    async def process_text_generation(self, generation_id: str) -> Dict[str, Any]: ...
    async def process_image_generation(self, generation_id: str) -> Dict[str, Any]: ...
    async def process_video_generation(self, generation_id: str) -> Dict[str, Any]: ...
    async def stream_text_generation(self, item_id: str, user_id: str, request: Dict[str, Any]) -> AsyncIterator[str]: ...

Import

from src.services.canvas import CanvasGenerationService

I/O Contract

Inputs

Name Type Required Description
generation_id str Yes CanvasItemGeneration UUID

Outputs

Name Type Description
process_text_generation dict {generation_id, status, text}
process_image_generation dict {generation_id, status, result_image_object_key}
process_video_generation dict {generation_id, status, provider_task_id or result_video_object_key}

Usage Examples

Processing a Canvas Image Generation

from src.services.canvas import CanvasGenerationService

service = CanvasGenerationService(db_session)
result = await service.process_image_generation(
    generation_id="gen-uuid"
)
print(f"Image stored at: {result['result_image_object_key']}")

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment