Prompts
Generate LLM instruction prompts from a block Registry (or a single block type) so models emit blocks the same registry can parse. See the Generating Prompts guide for usage. Registry.to_prompt(), Registry.register_template(), and Registry.serialize_block() are documented on the Registry & Models page.
hother.streamblocks.prompts
Prompt generation from block registries and block classes.
TemplateManager
Manage Jinja2 templates with version support for prompt A/B testing.
Built-in templates live in the package templates/ directory and are
named <mode>.jinja2 (default version) or <mode>_<version>.jinja2.
Custom templates can be registered at runtime via :meth:register_template.
Source code in src/hother/streamblocks/prompts/manager.py
get_template
Return the template for the given version and mode.
Custom-registered templates take priority over built-in package templates.
Source code in src/hother/streamblocks/prompts/manager.py
register_template
Register a custom template for one or both render modes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
str
|
Version identifier (e.g. "concise"). |
required |
template
|
str | Path
|
Template string, or a Path to a template file. |
required |
mode
|
str
|
"registry", "single", or "both". |
_MODE_BOTH
|
Source code in src/hother/streamblocks/prompts/manager.py
generate_block_prompt
generate_block_prompt(
block_class: type[Block[Any, Any]],
syntax: BaseSyntax,
*,
include_examples: bool = True,
template_version: str = "default",
description: str = "",
) -> str
Generate an instruction prompt for a single block type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block_class
|
type[Block[Any, Any]]
|
The block class to document. |
required |
syntax
|
BaseSyntax
|
Syntax used to describe the format and serialize examples. |
required |
include_examples
|
bool
|
Whether to render examples from |
True
|
template_version
|
str
|
Template version for A/B testing. |
'default'
|
description
|
str
|
Optional description overriding the block docstring. |
''
|
Returns:
| Type | Description |
|---|---|
str
|
The rendered prompt for this block type. |