TemplateConfig

Configure prompt templates for system, user, and response formatting

Customize prompt templates to control how agents receive instructions and format responses.

Diagram

Template Flow

📋 System

💬 Prompt

🤖 Agent

📝 Response

Quick Start

  1. Basic Templates

    Set custom templates:

    python
    from praisonaiagents import Agent
    from praisonaiagents.config import TemplateConfig
    
    agent = Agent(
        name="Custom Agent",
        instructions="You are a helpful assistant",
        templates=TemplateConfig(
            system="You are an expert in {domain}.",
            prompt="User query: {input}",
            response="Provide a detailed response."
        )
    )

Configuration Options

python
from praisonaiagents.config import TemplateConfig

config = TemplateConfig(
    # System template
    system=None,

    # Prompt template
    prompt=None,

    # Response template
    response=None,

    # Use system prompt
    use_system_prompt=True
)
ParameterTypeDefaultDescription
system`str \None`NoneSystem message template
prompt`str \None`NoneUser prompt template
response`str \None`NoneResponse format template
use_system_promptboolTrueInclude system prompt in messages

Common Patterns

Pattern 1: Domain Expert Template

python
from praisonaiagents import Agent
from praisonaiagents.config import TemplateConfig

agent = Agent(
    name="Legal Expert",
    instructions="Legal analysis",
    templates=TemplateConfig(
        system="""You are an expert legal analyst.
        Always cite relevant laws and precedents.
        Be precise and thorough in your analysis."""
    )
)

Pattern 2: Structured Response Template

python
from praisonaiagents import Agent
from praisonaiagents.config import TemplateConfig

agent = Agent(
    name="Report Agent",
    instructions="Generate reports",
    templates=TemplateConfig(
        response="""Format your response as:

## Summary
[Brief overview]

## Details
[Detailed analysis]

## Recommendations
[Action items]"""
    )
)

Pattern 3: No System Prompt

python
from praisonaiagents import Agent
from praisonaiagents.config import TemplateConfig

agent = Agent(
    name="Raw Agent",
    instructions="Direct interaction",
    templates=TemplateConfig(
        use_system_prompt=False
    )
)

Best Practices

Use System Templates for Persona

Define agent persona and behavior in the system template.

Use Response Templates for Formatting

Ensure consistent output format with response templates.

Keep Templates Focused

Each template should have a single, clear purpose.


Related