/ examples / middleware / configurable_model.py
configurable_model.py
 1  """
 2  Configurable Model Example - PraisonAI Agents
 3  
 4  Demonstrates runtime model switching without recreating the agent.
 5  """
 6  
 7  from praisonaiagents import Agent
 8  
 9  # Create agent with configurable model enabled
10  agent = Agent(
11      name="FlexBot",
12      instructions="You are a helpful assistant.",
13      llm="gpt-4o-mini",
14      llm_config={"configurable": True}
15  )
16  
17  if __name__ == "__main__":
18      # Default model call
19      print("Using default model (gpt-4o-mini)...")
20      # response = agent.chat("Say hello in 5 words")
21      
22      # Override model per-call
23      print("\nOverriding to different model...")
24      # response = agent.chat("Say hello in 5 words", config={"model": "gpt-4o"})
25      
26      # Override temperature
27      print("\nOverriding temperature...")
28      # response = agent.chat("Say hello creatively", config={"temperature": 0.9})
29      
30      print("\n✓ Configurable model example complete")
31      print("Note: Uncomment agent.chat() calls to run with API key")