You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version: v1.2.3 | Status: Active | Last Updated: March 2026
Overview
The prompt_engineering module provides template management, version tracking, optimization strategies, and evaluation scoring for prompts. It covers the full lifecycle from authoring and versioning through optimization and quality assessment.
Templates API
PromptTemplate (dataclass)
A reusable prompt template with {variable_name} placeholders.
Field
Type
Default
Description
name
str
(required)
Template name
template_str
str
(required)
Template string with {var} placeholders
variables
list[str]
auto-detected
Expected variable names
version
str
"1.0.0"
Version string
metadata
dict[str, Any]
{}
Arbitrary metadata
Methods:
Method
Signature
Returns
Description
render
(**kwargs: Any) -> str
str
Render with variable values. Raises KeyError if missing
validate
(**kwargs: Any) -> list[str]
list[str]
List of missing variable names
to_dict
() -> dict[str, Any]
dict
Convert to dictionary
from_dict
(data: dict) -> PromptTemplate
PromptTemplate
Create from dictionary (classmethod)
TemplateRegistry
Registry for managing collections of prompt templates.
TemplateRegistry(config: Any|None=None)
Method
Signature
Returns
Description
add
(template: PromptTemplate) -> None
None
Register. Raises ValueError if name exists
update
(template: PromptTemplate) -> None
None
Add or replace
get
(name: str) -> PromptTemplate
PromptTemplate
Retrieve. Raises KeyError if not found
remove
(name: str) -> PromptTemplate
PromptTemplate
Remove and return. Raises KeyError if not found
list
() -> list[str]
list[str]
Sorted template names
list_templates
() -> list[PromptTemplate]
list[PromptTemplate]
All templates sorted by name
render
(template_name, /, **kwargs) -> str
str
Render template by name
search
(query: str) -> list[PromptTemplate]
list[PromptTemplate]
Search by name or metadata keyword
export_all
() -> list[dict]
list[dict]
Export all as dictionaries
import_all
(data, overwrite=False) -> int
int
Import from dicts; returns count imported
Properties:size (number of templates).
get_default_registry
defget_default_registry() ->TemplateRegistry
Returns the module-level default template registry singleton.
Versioning API
PromptVersion (dataclass)
Field
Type
Default
Description
version
str
(required)
Version string (e.g., "1.0.0")
template
PromptTemplate
(required)
The template at this version
created_at
datetime
now (UTC)
Creation timestamp
changelog
str
""
Description of changes
author
str
""
Who made the change
metadata
dict[str, Any]
{}
Additional metadata
Methods:to_dict(), from_dict() (classmethod).
VersionManager
Manages version history for prompt templates with diff and rollback.