Skip to content

Prompt Configuration

Configuration classes for prompt management.

PromptConfig

Configuration for the PromptManager.

Quick Example

from pathlib import Path
from mamba_agents.prompts import PromptConfig, PromptManager

config = PromptConfig(
    prompts_dir=Path("./my_prompts"),
    default_version="v2",
    file_extensions=[".jinja2", ".md"],  # Both formats supported
    enable_caching=True,
    strict_mode=False,
)

manager = PromptManager(config=config)

Configuration Options

Option Type Default Description
prompts_dir Path "prompts" Directory containing templates
default_version str "v1" Default version when not specified
file_extensions list[str] [".jinja2", ".md"] Supported template file extensions
enable_caching bool True Cache loaded templates
strict_mode bool False Raise on missing variables

Backward Compatibility

The file_extension property (singular) is still available for reading and returns the first extension in the list.

API Reference

PromptConfig

Bases: BaseModel

Configuration for prompt management.

ATTRIBUTE DESCRIPTION
prompts_dir

Directory containing prompt templates.

TYPE: Path

default_version

Default version to use when not specified.

TYPE: str

file_extensions

Supported file extensions for prompt templates.

TYPE: list[str]

enable_caching

Whether to cache loaded templates.

TYPE: bool

strict_mode

Whether to raise on missing template variables.

TYPE: bool

file_extension property

file_extension: str

Get the primary file extension (for backward compatibility).

RETURNS DESCRIPTION
str

The first file extension in the list.


TemplateConfig

Reference to a prompt template for use with Agent.

Quick Example

from mamba_agents import Agent
from mamba_agents.prompts import TemplateConfig

# Basic usage
config = TemplateConfig(
    name="system/assistant",
    variables={"name": "Helper"}
)

agent = Agent("gpt-4o", system_prompt=config)

# With specific version
config = TemplateConfig(
    name="system/assistant",
    version="v2",
    variables={"name": "Helper", "tone": "professional"}
)

Configuration Options

Option Type Default Description
name str required Template name (e.g., "system/assistant")
version str | None None Template version (uses default if None)
variables dict {} Variables to pass when rendering

API Reference

TemplateConfig

Bases: BaseModel

Reference to a prompt template.

Use this to specify which template to load and what variables to pass when rendering.

ATTRIBUTE DESCRIPTION
name

Template name (e.g., "system/assistant").

TYPE: str

version

Template version. None uses default.

TYPE: str | None

variables

Variables to pass when rendering.

TYPE: dict[str, Any]

Example

config = TemplateConfig( ... name="system/assistant", ... variables={"name": "Code Helper"} ... )