prompt ¶
Prompt pipeline for the streaming server.
- :mod:
providers— LLM backend abstraction + built-in adapters - :mod:
enhancer— provider-agnostic enhance / auto-extend / rewrite operations on top of the provider layer
All of this is optional; the streaming server runs fine without it (PR 7.5's skeleton never invokes the enhancer). When the operator enables ServeConfig.streaming.prompt.enabled, the server routes each session_init_v2 curated prompt through enhance before the first segment.
Classes¶
fastvideo.entrypoints.streaming.prompt.LLMProvider ¶
Bases: Protocol
Provider interface every LLM adapter implements.
Providers are async-first because every built-in implementation talks to an HTTP API. Synchronous providers can wrap their call in asyncio.to_thread internally.
fastvideo.entrypoints.streaming.prompt.LLMProviderError ¶
Bases: RuntimeError
Raised when an LLM provider fails a request.
retryable controls whether the enhancer falls back to the next provider. It is settable per-instance so the same exception type can describe retryable transport errors (5xx, 429) and non-retryable client errors (4xx auth/bad-request) without forcing a separate subclass for every status family.
Source code in fastvideo/entrypoints/streaming/prompt/providers/base.py
fastvideo.entrypoints.streaming.prompt.LLMTimeoutError ¶
LLMTimeoutError(message: str)
Bases: LLMProviderError
Raised when an LLM provider times out — always retryable.
Source code in fastvideo/entrypoints/streaming/prompt/providers/base.py
fastvideo.entrypoints.streaming.prompt.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.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.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.