03 Automatic Cultural Management
Automatically update cultural knowledge based on Agent interactions.
1"""203 Automatic Cultural Management3=============================45Automatically update cultural knowledge based on Agent interactions.6"""78from kern.agent import Agent9from kern.db.sqlite import SqliteDb10from kern.models.openai import OpenAIResponses1112# ---------------------------------------------------------------------------13# Step 1. Initialize the database (same one used in 01_create_cultural_knowledge.py)14# ---------------------------------------------------------------------------15db = SqliteDb(db_file="tmp/demo.db")1617# ---------------------------------------------------------------------------18# Create Agent19# ---------------------------------------------------------------------------20# The Agent will automatically add or update cultural knowledge after each run.21agent = Agent(22 db=db,23 model=OpenAIResponses(id="gpt-5.2"),24 update_cultural_knowledge=True, # enables automatic cultural updates25)2627# ---------------------------------------------------------------------------28# Run Agent29# ---------------------------------------------------------------------------30if __name__ == "__main__":31 # ---------------------------------------------------------------------------32 # Step 3. Ask the Agent to generate a response33 # ---------------------------------------------------------------------------34 agent.print_response(35 "What would be the best way to cook ramen? Detailed and specific instructions generally work better than general advice.",36 stream=True,37 markdown=True,38 )Run the Example
1# Clone and setup repo2git clone https://github.com/kern-ai/kern.git3cd kern/cookbook/02_agents/14_advanced45# Create and activate virtual environment6./scripts/demo_setup.sh7source .venvs/demo/bin/activate89python 03_automatic_cultural_management.py