TemplateConfig
Configure prompt templates for system, user, and response formatting
Customize prompt templates to control how agents receive instructions and format responses.
Quick Start
- 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
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
)| Parameter | Type | Default | Description | |
|---|---|---|---|---|
system | `str \ | None` | None | System message template |
prompt | `str \ | None` | None | User prompt template |
response | `str \ | None` | None | Response format template |
use_system_prompt | bool | True | Include system prompt in messages |
Common Patterns
Pattern 1: Domain Expert Template
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
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
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.