00_agent_reflection_basic.py
1 """ 2 Basic Reflection Configuration Example 3 4 Demonstrates using reflection for self-improvement. 5 """ 6 import os 7 from praisonaiagents import Agent 8 9 # Ensure API key is set from environment 10 assert os.getenv("OPENAI_API_KEY"), "OPENAI_API_KEY must be set" 11 12 # Enable reflection with defaults 13 agent = Agent( 14 instructions="You are a helpful math tutor.", 15 reflection=True, 16 ) 17 18 # Disable reflection (default) 19 agent_no_reflect = Agent( 20 instructions="You are a helpful assistant.", 21 reflection=False, 22 ) 23 24 if __name__ == "__main__": 25 print("Testing reflection...") 26 27 print(f"Reflection agent self_reflect: {agent.self_reflect}") 28 print(f"No-reflect agent self_reflect: {agent_no_reflect.self_reflect}") 29 30 result = agent.chat("Solve: What is 15% of 80?") 31 print(f"Result: {result}") 32 33 print("\nReflection tests passed!")