-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
This guide explains how to configure the Cognitive Engine for different use cases.
The Cognitive Engine can be configured using environment variables or a .env file.
OPENAI_API_KEY=your_openai_api_key_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here
DEFAULT_LLM_PROVIDER=openaiOPENAI_API_KEY: Your OpenAI API key. Get it from https://platform.openai.com/api-keys
ANTHROPIC_API_KEY: Your Anthropic API key. Get it from https://console.anthropic.com/
DEFAULT_LLM_PROVIDER: Which LLM provider to use by default. Options: openai or anthropic
Note: You need at least one API key configured. The system will use the available provider.
MIN_ITERATIONS=3
MAX_ITERATIONS=50
EARLY_STOP_CONFIDENCE=0.95
CONFIDENCE_THRESHOLD=0.7MIN_ITERATIONS: Minimum number of cognitive iterations before considering early stop. Default: 3
MAX_ITERATIONS: Maximum number of cognitive iterations to prevent infinite loops. Default: 50
EARLY_STOP_CONFIDENCE: Confidence threshold for early stopping. If the best thought exceeds this confidence, the engine stops early. Default: 0.95
CONFIDENCE_THRESHOLD: Minimum confidence required for acceptable output. If no thought meets this threshold after MAX_ITERATIONS, the best available thought is used. Default: 0.7
ENABLE_DASHBOARD=true
DASHBOARD_PORT=8000
DASHBOARD_HOST=0.0.0.0ENABLE_DASHBOARD: Enable or disable the real-time cognitive telemetry dashboard. Default: true
DASHBOARD_PORT: Port for the dashboard WebSocket server. Default: 8000
DASHBOARD_HOST: Host address for the dashboard server. Default: 0.0.0.0 (all interfaces)
MEMORY_DB_PATH=cognitive_engine.db
MAX_MEMORY_SIZE=10000
MEMORY_RETENTION_DAYS=365MEMORY_DB_PATH: Path to the SQLite database file for memory persistence. Default: cognitive_engine.db
MAX_MEMORY_SIZE: Maximum number of entries to store in memory. Default: 10000
MEMORY_RETENTION_DAYS: Number of days to retain episodic memory entries. Default: 365
LOG_LEVEL=INFO
LOG_FILE=cognitive_engine.log
LOG_FORMAT=%(asctime)s - %(name)s - %(levelname)s - %(message)s
LOG_TO_CONSOLE=true
LOG_TO_FILE=trueLOG_LEVEL: Logging level. Options: DEBUG, INFO, WARNING, ERROR, CRITICAL. Default: INFO
LOG_FILE: Path to the log file. Default: cognitive_engine.log
LOG_FORMAT: Log message format. Default: %(asctime)s - %(name)s - %(levelname)s - %(message)s
LOG_TO_CONSOLE: Enable console logging. Default: true
LOG_TO_FILE: Enable file logging. Default: true
ENABLE_LEARNING=true
LEARNING_INTERVAL=100
PATTERN_THRESHOLD=5
RULE_EFFECTIVENESS_THRESHOLD=0.7ENABLE_LEARNING: Enable the learning system. Default: true
LEARNING_INTERVAL: Number of processing cycles between learning operations. Default: 100
PATTERN_THRESHOLD: Minimum frequency for a pattern to be considered significant. Default: 5
RULE_EFFECTIVENESS_THRESHOLD: Minimum effectiveness score for a rule to be retained. Default: 0.7
ENABLE_PROMPT_EVOLUTION=false
PROMPT_EVOLUTION_INTERVAL=1000
MUTATION_RATE=0.1
PERFORMANCE_BASELINE_LOCK=trueENABLE_PROMPT_EVOLUTION: Enable prompt evolution system. Default: false (experimental)
PROMPT_EVOLUTION_INTERVAL: Number of processing cycles between prompt evolution attempts. Default: 1000
MUTATION_RATE: Maximum rate of prompt change per evolution cycle (0-1). Default: 0.1
PERFORMANCE_BASELINE_LOCK: Prevent performance regression below original baseline. Default: true
ENABLE_AGENT=true
AGENT_STEP_LIMIT=100
AGENT_GOAL_VALIDATION=true
AGENT_MEMORY_CONTROL=trueENABLE_AGENT: Enable autonomous agent mode. Default: true
AGENT_STEP_LIMIT: Maximum number of steps an agent can take. Default: 100
AGENT_GOAL_VALIDATION: Enable goal validation for safety. Default: true
AGENT_MEMORY_CONTROL: Enable memory control for agents. Default: true
Create a .env file in the project root:
cp .env.example .envEdit the .env file with your configuration:
# LLM Provider
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
DEFAULT_LLM_PROVIDER=openai
# Engine
MIN_ITERATIONS=3
MAX_ITERATIONS=50
EARLY_STOP_CONFIDENCE=0.95
CONFIDENCE_THRESHOLD=0.7
# Dashboard
ENABLE_DASHBOARD=true
DASHBOARD_PORT=8000
# Memory
MEMORY_DB_PATH=cognitive_engine.db
MAX_MEMORY_SIZE=10000
# Logging
LOG_LEVEL=INFO
LOG_FILE=cognitive_engine.log
# Learning
ENABLE_LEARNING=true
LEARNING_INTERVAL=100
# Prompt Evolution (experimental)
ENABLE_PROMPT_EVOLUTION=false
# Agent
ENABLE_AGENT=true
AGENT_STEP_LIMIT=100You can also configure the engine programmatically:
from core.config import Config
config = Config(
min_iterations=5,
max_iterations=30,
early_stop_confidence=0.9,
confidence_threshold=0.75,
enable_dashboard=True,
dashboard_port=8080,
default_llm_provider="anthropic"
)
from core.engine import CognitiveEngine
engine = CognitiveEngine(config)For scenarios where speed is more important than depth of reasoning:
MIN_ITERATIONS=1
MAX_ITERATIONS=5
EARLY_STOP_CONFIDENCE=0.8
CONFIDENCE_THRESHOLD=0.6
ENABLE_LEARNING=false
ENABLE_DASHBOARD=falseFor scenarios where quality is more important than speed:
MIN_ITERATIONS=5
MAX_ITERATIONS=100
EARLY_STOP_CONFIDENCE=0.98
CONFIDENCE_THRESHOLD=0.8
ENABLE_LEARNING=true
ENABLE_DASHBOARD=trueFor development and debugging:
LOG_LEVEL=DEBUG
LOG_TO_CONSOLE=true
LOG_TO_FILE=true
ENABLE_DASHBOARD=true
MIN_ITERATIONS=2
MAX_ITERATIONS=10For production deployment:
LOG_LEVEL=INFO
LOG_TO_CONSOLE=false
LOG_TO_FILE=true
ENABLE_DASHBOARD=false
MIN_ITERATIONS=3
MAX_ITERATIONS=50
ENABLE_PROMPT_EVOLUTION=falseFor research and experimentation with prompt evolution:
ENABLE_PROMPT_EVOLUTION=true
PROMPT_EVOLUTION_INTERVAL=500
MUTATION_RATE=0.2
PERFORMANCE_BASELINE_LOCK=true
ENABLE_LEARNING=true
ENABLE_DASHBOARD=true
LOG_LEVEL=DEBUGThe system validates configuration at startup. Common validation errors:
Error: No LLM API key configured
Solution: Set either OPENAI_API_KEY or ANTHROPIC_API_KEY
Error: MIN_ITERATIONS must be less than MAX_ITERATIONS
Solution: Ensure MIN_ITERATIONS < MAX_ITERATIONS
Error: Confidence values must be between 0 and 1
Solution: Ensure all confidence values are in range [0, 1]
Error: Dashboard port already in use
Solution: Change DASHBOARD_PORT to a different port
You can add custom LLM providers by extending the LLM client:
from llm.client import LLMClient
class CustomLLMClient(LLMClient):
def __init__(self):
super().__init__(provider="custom")
# Custom initializationYou can use a different memory backend by implementing the memory interface:
from core.memory import MemoryBackend
class CustomMemoryBackend(MemoryBackend):
def store(self, event):
# Custom storage logic
pass
def retrieve(self, query):
# Custom retrieval logic
passYou can implement custom thought scoring:
from utils.scoring import ThoughtScorer
class CustomScorer(ThoughtScorer):
def score_thought(self, thought):
# Custom scoring logic
score = super().score_thought(thought)
# Add custom factors
return score-
Security: Never commit
.envfiles with real API keys to version control - Environment-Specific: Use different configurations for development, staging, and production
- Documentation: Document custom configurations for your team
- Validation: Test configuration changes in a development environment first
- Monitoring: Monitor the impact of configuration changes on system performance
- Backups: Backup configuration files and database before major changes
-
Version Control: Keep
.env.examplein version control with placeholder values
If configuration variables aren't being loaded:
- Check that
.envfile exists in project root - Verify variable names are correct (no typos)
- Ensure no extra spaces around
= - Check file encoding (should be UTF-8)
- Verify python-dotenv is installed
If the dashboard won't start:
- Check that
ENABLE_DASHBOARD=true - Verify
DASHBOARD_PORTis not in use - Check firewall settings
- Verify FastAPI and Uvicorn are installed
- Check logs for specific error messages
If memory database has issues:
- Check
MEMORY_DB_PATHis writable - Verify SQLite is installed
- Check disk space
- Try deleting the database file and letting it recreate
- Check file permissions
If LLM API calls fail:
- Verify API keys are correct
- Check API quota/limits
- Verify internet connectivity
- Check API service status
- Try switching to alternate provider
When upgrading versions, configuration may change:
- Check release notes for configuration changes
- Backup current
.envfile - Update
.env.examplewith new variables - Test new configuration in development
- Deploy to production after validation
For configuration issues:
- Check logs in
cognitive_engine.logfor detailed error information - Review this documentation for common issues
- Contact: autobotsolution@gmail.com