Configuration

Configure all aspects of your agent

Configure agents with sensible defaults and easy customization.

Diagram

Configuration Levels

Default

Bool

Config

Instance

Configuration Pattern

Every feature follows the same pattern – start simple, add detail as needed:

  1. Level 1: Minimal
    rust
    use praisonai::Agent;
    
    // Uses all defaults - just provide name
    let agent = Agent::new()
        .name("Assistant")
        .build()?;
  2. Level 2: Basic Settings
    rust
    use praisonai::Agent;
    
    // Common configuration options
    let agent = Agent::new()
        .name("Assistant")
        .instructions("You are a helpful assistant")
        .model("gpt-4o")
        .memory(true)      // Enable memory
        .verbose(true)     // Enable verbose output
        .build()?;
  3. Level 3: Full Configuration
    rust
    use praisonai::{Agent, MemoryConfig};
    
    // Complete configuration with all options
    let agent = Agent::new()
        .name("Research Assistant")
        .instructions("You research topics thoroughly")
        .model("gpt-4o")
        .api_key("sk-...")
        .base_url("https://api.openai.com/v1")
        .temperature(0.7)
        .max_tokens(4096)
        .memory_config(MemoryConfig::new().max_messages(100))
        .max_iterations(15)
        .stream(true)
        .verbose(true)
        .build()?;

All Configurations

ConfigPurposeDefault
MemoryConfigConversation memoryShort-term enabled
PlanningConfigPlanning modeDisabled
ExecutionConfigLimits and timeouts10 iterations, 300s
OutputConfigOutput formatVerbose
KnowledgeConfigRAG settingsAuto-retrieve
GuardrailConfigSafety validationDisabled

Environment Variables

Configure via environment:

bash
export OPENAI_API_KEY="your-key"
export PRAISONAI_MODEL="gpt-4o"
export PRAISONAI_VERBOSE="true"
export PRAISONAI_TIMEOUT="60"

Best Practices

Start with defaults

Defaults are chosen for common use cases. Customize only when needed.

Use environment variables for secrets

Never hardcode API keys in source code.

Use booleans for quick toggles

Use Config classes when you need fine-grained control.


Related