00_agent_templates_basic.py
1 """ 2 TemplateConfig Example 3 4 Demonstrates using TemplateConfig for custom prompt templates. 5 """ 6 import os 7 from praisonaiagents import Agent, TemplateConfig 8 9 # Ensure API key is set from environment 10 assert os.getenv("OPENAI_API_KEY"), "OPENAI_API_KEY must be set" 11 12 # Custom system template 13 agent = Agent( 14 instructions="You are a helpful assistant.", 15 templates=TemplateConfig( 16 system="You are a professional technical writer. Always be concise and clear.", 17 use_system_prompt=True, 18 ), 19 ) 20 21 # Custom prompt and response templates 22 agent_custom = Agent( 23 instructions="You are a helpful assistant.", 24 templates=TemplateConfig( 25 system="You are an expert in Python programming.", 26 prompt=None, # Use default 27 response=None, # Use default 28 use_system_prompt=True, 29 ), 30 ) 31 32 if __name__ == "__main__": 33 print("Testing TemplateConfig...") 34 35 result = agent.chat("Explain what an API is in one sentence.") 36 print(f"Result: {result}") 37 38 print("\nTemplateConfig tests passed!")