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 PromptService generate prompts batch

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

Overview

Service that batch-generates image prompts for all sentences in a chapter using an LLM with style presets and concurrency control.

Description

PromptService.generate_prompts_batch loads all sentences for a given chapter, creates a provider from the user's API key, and concurrently generates Stable Diffusion-style image prompts for each sentence. The style parameter selects a system prompt preset (cinematic, anime, illustration, ink) that controls the aesthetic of the generated prompts. An optional custom_prompt can override the system prompt entirely.

Each sentence's image_prompt field is updated with the generated English prompt, and the sentence status is set to GENERATED_PROMPTS.

Usage

Import when you need to generate image prompts for a chapter's sentences. Called by the content generation Celery task.

Code Reference

Source Location

Signature

class PromptService(BaseService):
    async def generate_prompts_batch(
        self,
        chapter_id: str,
        api_key_id: str,
        style: str = "cinematic",
        model: str = None,
        custom_prompt: str = None
    ) -> dict:
        """
        Args:
            chapter_id: chapter UUID
            api_key_id: encrypted API key ID
            style: style preset (cinematic/anime/illustration/ink)
            model: LLM model name
            custom_prompt: custom system prompt override

        Returns:
            Dict with total, success, failed counts
        """

Import

from src.services.prompt import PromptService

I/O Contract

Inputs

Name Type Required Description
chapter_id str Yes Chapter UUID to process
api_key_id str Yes Encrypted API key ID
style str No Style preset (default "cinematic")
model str No LLM model name
custom_prompt str No Custom system prompt override

Outputs

Name Type Description
return value dict {total, success, failed}
DB side effects — Updates Sentence.image_prompt; sets sentence status to GENERATED_PROMPTS

Usage Examples

Batch Prompt Generation

from src.services.prompt import PromptService

service = PromptService(db_session)
result = await service.generate_prompts_batch(
    chapter_id="chapter-uuid",
    api_key_id="key-uuid",
    style="anime",
    model="gpt-4o",
)
print(f"Generated prompts: {result['success']}/{result['total']}")

Related Pages

Implements Principle

Requires Environment

Page Connections

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