enhancer ¶
Provider-agnostic prompt orchestration for the streaming server.
Three operations the streaming server needs:
enhance— polish a user prompt (add cinematic detail, fix syntax)auto_extend— generate a follow-on prompt for loop generationrewrite— rewrite a seed prompt for a user-directed rewrite flow
All three share the same orchestration: pick a provider in priority order, submit an LLMRequest, fall back to the next provider on retryable errors, and surface a structured :class:LLMResponse back to the caller.
System prompts are loaded from system_prompt_dir on construction and can be hot-reloaded via :meth:PromptEnhancer.reload_system_prompts. The streaming server's management endpoint calls that method in response to a rewrite_seed_prompts_started frame.
Classes¶
fastvideo.entrypoints.streaming.prompt.enhancer.PromptEnhancer ¶
PromptEnhancer(*, providers: Sequence[LLMProvider], model: str, timeout_ms: int = 20000, temperature: float = 0.7, max_tokens: int | None = 256, system_prompt_dir: str | None = None)
Orchestrates prompt operations across a priority-ordered provider list with structured fallback + hot-reloadable system prompts.
Usage::
enhancer = PromptEnhancer(
providers=[CerebrasProvider(), GroqProvider()],
model="gpt-oss-120b",
system_prompt_dir="/etc/fastvideo/prompts",
)
response = await enhancer.enhance("a fox running through snow")
Source code in fastvideo/entrypoints/streaming/prompt/enhancer.py
Methods:¶
fastvideo.entrypoints.streaming.prompt.enhancer.PromptEnhancer.register_provider ¶
register_provider(provider: LLMProvider, *, priority: int = -1) -> None
Insert an additional provider. priority=0 makes it primary; priority=-1 (default) appends as a fallback.
Source code in fastvideo/entrypoints/streaming/prompt/enhancer.py
fastvideo.entrypoints.streaming.prompt.enhancer.PromptEnhancer.reload_system_prompts ¶
Re-read the system prompt files from system_prompt_dir.
The streaming server exposes this via a management endpoint so operators can iterate on prompt templates without restarting workers.