diff --git a/.gitignore b/.gitignore index fac285d..ffb3cfd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,102 +1,72 @@ -# Byte-compiled / optimized / DLL files +``` +# Compiled and build artifacts +*.pyc __pycache__/ -**/__pycache__/ -*.py[cod] -*$py.class -# Virtual environments +*.o +*.obj +dist/ +build/ +*.so +*.dll +*.exe +*.class + +# Dependencies .venv/ -**/.venv/ -env/ -**/env/ venv/ -**/venv/ -# Logs and databases +node_modules/ +.mypy_cache/ +.pytest_cache/ +target/ +.gradle/ + +# Logs and temp files *.log -*.db -*.sqlite3 -# Environment and lock files -.env -.env.* -.venv -Pipfile.lock -poetry.lock -uv.lock -# Ignore temporary editor files +*.tmp *.swp *.swo -*~ + +# Environment +.env +.env.local +*.env.* + +# Editors .vscode/ .idea/ -*.sublime-project -*.sublime-workspace -# OS-specific files +*.swp +*.swo + +# System files .DS_Store Thumbs.db -chroma_db/ -# Custom -.cursorignore - -# PyInstaller -# build/ # Already included in Packaging section -# dist/ # Already included in Packaging section -# *.spec # Already included in Packaging section - -# Jupyter Notebook checkpoints -.ipynb_checkpoints/ - -# Coverage and testing +# Coverage +coverage/ htmlcov/ .coverage -.cache/ -pytest_cache/ -.tox/ - -# Mypy and Pyright -.mypy_cache/ -.pyright/ - -# Packaging -*.egg -*.egg-info/ -dist/ -build/ -*.spec - -modules/knowledge_compression/compressed_memory.json - -# RAVANA AGI specific -.qoder/ - -knowledge_id_map.pkl -knowledge_index.faiss - -snake_agent_state.json -shared_memory/ - -user_data/ - -snake_logs/ -backups/ - -snake_vltm_storage/ -vltm_storage/ -test_snake_logs/ - -performance_data/ -.benchmarks/ -.qwen/ - -profiles/ - -SNAKE_AGENT_FINAL_SUMMARY.md -SNAKE_AGENT_SUCCESS_SUMMARY.md - -snake_agent_optimized_config.bat -snake_agent_optimized_config.sh -enhanced_snake_state.json -final_demonstration.py -optimize_code_snake.py -self_goals.json -.snake_index.json \ No newline at end of file +# Compressed files +*.zip +*.gz +*.tar +*.tgz +*.bz2 +*.xz +*.7z +*.rar +*.zst +*.lz4 +*.lzh +*.cab +*.arj +*.rpm +*.deb +*.Z +*.lz +*.lzo +*.tar.gz +*.tar.bz2 +*.tar.xz +*.tar.zst +``` \ No newline at end of file diff --git a/SIMPLIFIED_CONFIG_GUIDE.md b/SIMPLIFIED_CONFIG_GUIDE.md new file mode 100644 index 0000000..1899d13 --- /dev/null +++ b/SIMPLIFIED_CONFIG_GUIDE.md @@ -0,0 +1,151 @@ +# Simplified Configuration Guide for RAVANA AGI + +## Overview + +This guide explains the simplified configuration system for the RAVANA AGI project. The goal is to reduce complexity while maintaining essential functionality. + +## Key Changes + +### 1. Consolidated Configuration +- **Before**: Multiple configuration files (`core/config.json`, `analysis/config.json`, `core/config.py`) with complex nested structures +- **After**: Single simplified configuration file (`simple_config.json`) with clear, logical groupings + +### 2. Reduced Complexity +- Simplified model configuration from separate coding/reasoning models to a single primary model +- Consolidated API keys to essential providers only +- Streamlined settings into logical categories + +### 3. Environment Variable Support +- All configuration values can be overridden via environment variables +- Maintains compatibility with existing deployment practices + +## Configuration Structure + +The simplified configuration is organized into these main sections: + +### System +- `name`: Name of the system (default: "RAVANA") +- `database_url`: Database connection string (default: "sqlite:///ravana_agi.db") +- `log_level`: Logging level (default: "INFO") + +### Operational +- `curiosity_chance`: Probability of curiosity-driven behavior (0.0 to 1.0) +- `reflection_chance`: Probability of reflection (0.0 to 1.0) +- `loop_sleep_duration`: Sleep duration between loops in seconds +- `max_iterations`: Maximum iterations for processes + +### Models +- `primary`: Configuration for the main AI model + - `provider`: AI provider (e.g., "ollama", "openai") + - `model_name`: Name of the model + - `base_url`: API endpoint + - `temperature`: Creativity parameter + - `max_tokens`: Maximum tokens to generate + - `timeout`: Request timeout in seconds + +### API Keys +- `electronhub`: API key for ElectronHub provider +- `zuki`: API key for Zuki provider +- `gemini`: API key for Google Gemini provider + +### Memory +- `embedding_model`: Model used for embeddings +- `embedding_use_cuda`: Whether to use CUDA for embeddings + +### Agents +- `snake_agent`: Configuration for the Snake Agent + - `enabled`: Whether the agent is enabled + - `interval`: Interval between agent runs in seconds + +### Services +- `blog`: Blog publishing service + - `enabled`: Whether blog publishing is enabled + - `api_url`: Blog API endpoint +- `conversational_ai`: Conversational AI service + - `enabled`: Whether conversational AI is enabled + +### Scheduling +- `data_collection_interval`: How often to collect data (seconds) +- `event_detection_interval`: How often to detect events (seconds) +- `knowledge_compression_interval`: How often to compress knowledge (seconds) + +### Persona +- `name`: Name of the AI persona +- `creativity`: Creativity level (0.0 to 1.0) + +### Shutdown +- `timeout`: Shutdown timeout in seconds +- `graceful_shutdown_enabled`: Whether graceful shutdown is enabled + +## Usage + +### Loading Configuration + +```python +from core.simple_config import get_config + +config = get_config() + +# Access configuration values +print(config.system_name) +print(config.primary_model['model_name']) +``` + +### Environment Variables + +All configuration values can be overridden using environment variables: + +```bash +export SYSTEM_NAME="MyRAVANA" +export PRIMARY_MODEL_NAME="llama3.1:70b" +export CURIOSITY_CHANCE=0.5 +``` + +### Configuration File + +The configuration can also be loaded from a JSON file: + +```python +from core.simple_config import SimpleConfig + +config = SimpleConfig() +config.load_from_file("simple_config.json") +``` + +## Migration Guide + +To migrate from the old configuration system: + +1. Update your imports to use `core.simple_config` instead of `core.config` +2. Replace complex model configurations with the simplified primary model +3. Consolidate API keys to the essential providers +4. Use the new logical groupings for configuration values + +## Benefits + +1. **Easier Maintenance**: Single configuration file with clear structure +2. **Better Readability**: Logical groupings make it easy to find settings +3. **Simplified Code**: Reduced complexity in configuration handling +4. **Environment Support**: Full compatibility with environment variables +5. **Backward Compatibility**: Existing environment variables still work + +## Example Configuration + +```json +{ + "system": { + "name": "RAVANA", + "database_url": "sqlite:///ravana_agi.db", + "log_level": "INFO" + }, + "operational": { + "curiosity_chance": 0.4, + "reflection_chance": 0.15, + "loop_sleep_duration": 7, + "max_iterations": 15 + } + // ... other sections +} +``` + +This simplified configuration system maintains all essential functionality while reducing complexity and improving maintainability. \ No newline at end of file diff --git a/core/simple_config.py b/core/simple_config.py new file mode 100644 index 0000000..b67e218 --- /dev/null +++ b/core/simple_config.py @@ -0,0 +1,165 @@ +""" +Simplified Configuration System for RAVANA AGI + +This module provides a simplified configuration system that reduces complexity +while maintaining essential functionality for the RAVANA AGI system. +""" + +import os +import json +from typing import Dict, Any, Optional + + +class SimpleConfig: + """ + Simplified configuration class for RAVANA AGI system. + """ + + def __init__(self): + # Basic system settings + self.system_name = os.environ.get("SYSTEM_NAME", "RAVANA") + self.database_url = os.environ.get("DATABASE_URL", "sqlite:///ravana_agi.db") + self.log_level = os.environ.get("LOG_LEVEL", "INFO") + + # Core operational settings + self.curiosity_chance = float(os.environ.get("CURIOSITY_CHANCE", 0.4)) + self.reflection_chance = float(os.environ.get("REFLECTION_CHANCE", 0.15)) + self.loop_sleep_duration = int(os.environ.get("LOOP_SLEEP_DURATION", 7)) + self.max_iterations = int(os.environ.get("MAX_ITERATIONS", 15)) + + # Model configuration - simplified to one primary model + self.primary_model = { + 'provider': os.environ.get("PRIMARY_MODEL_PROVIDER", "ollama"), + 'model_name': os.environ.get("PRIMARY_MODEL_NAME", "llama3.1:8b"), + 'base_url': os.environ.get("OLLAMA_BASE_URL", "http://localhost:11434"), + 'temperature': float(os.environ.get("MODEL_TEMPERATURE", "0.7")), + 'max_tokens': int(os.environ.get("MODEL_MAX_TOKENS", "2048")), + 'timeout': int(os.environ.get("MODEL_TIMEOUT", "300")) + } + + # API keys - simplified to essential providers + self.api_keys = { + 'electronhub': os.environ.get("ELECTRONHUB_API_KEY", "ek-sVvxMYfdFQ0Kl6Aj2tmV7b8n5v0Y0sDHVsOUZWyx2vbs0AbuAc"), + 'zuki': os.environ.get("ZUKI_API_KEY", "985160dfa1fd499fd12af708d16552e37a8c6f77cbfb50ae400e3ff33fbd791bc7b3b82625379a1f5ca7568f1ee04eb81a0f8c06f0ba6c276d3dddfe13e9c18d"), + 'gemini': os.environ.get("GEMINI_API_KEY", "AIzaSyBW-aVU-x7JCjBJVVKjPGUacups0-GBHvQ") + } + + # Memory and embedding settings + self.embedding_model = os.environ.get("EMBEDDING_MODEL", "all-MiniLM-L6-v2") + self.embedding_use_cuda = self._str_to_bool(os.environ.get("EMBEDDING_USE_CUDA", "True")) + + # Snake Agent settings - simplified + self.snake_agent_enabled = self._str_to_bool(os.environ.get("SNAKE_AGENT_ENABLED", "True")) + self.snake_agent_interval = int(os.environ.get("SNAKE_AGENT_INTERVAL", 180)) + + # Shutdown settings + self.shutdown_timeout = int(os.environ.get("SHUTDOWN_TIMEOUT", 30)) + self.graceful_shutdown_enabled = self._str_to_bool(os.environ.get("GRACEFUL_SHUTDOWN_ENABLED", "True")) + + # Blog settings + self.blog_enabled = self._str_to_bool(os.environ.get("BLOG_ENABLED", "True")) + self.blog_api_url = os.environ.get("BLOG_API_URL", "https://ravana-blog.netlify.app/api/publish") + + # Conversational AI settings + self.conversational_ai_enabled = self._str_to_bool(os.environ.get("CONVERSATIONAL_AI_ENABLED", "True")) + + # Background task intervals + self.data_collection_interval = int(os.environ.get("DATA_COLLECTION_INTERVAL", 1800)) + self.event_detection_interval = int(os.environ.get("EVENT_DETECTION_INTERVAL", 300)) + self.knowledge_compression_interval = int(os.environ.get("KNOWLEDGE_COMPRESSION_INTERVAL", 7200)) + + # Persona settings + self.persona_name = os.environ.get("PERSONA_NAME", "Ravana") + self.persona_creativity = float(os.environ.get("PERSONA_CREATIVITY", 0.7)) + + def _str_to_bool(self, value: str) -> bool: + """Convert string to boolean.""" + if isinstance(value, bool): + return value + if isinstance(value, str): + return value.lower() in ('true', '1', 'yes', 'on') + return bool(value) + + def get_config_dict(self) -> Dict[str, Any]: + """Return configuration as a dictionary.""" + return { + 'system_name': self.system_name, + 'database_url': self.database_url, + 'log_level': self.log_level, + 'curiosity_chance': self.curiosity_chance, + 'reflection_chance': self.reflection_chance, + 'loop_sleep_duration': self.loop_sleep_duration, + 'max_iterations': self.max_iterations, + 'primary_model': self.primary_model, + 'api_keys': self.api_keys, + 'embedding_model': self.embedding_model, + 'embedding_use_cuda': self.embedding_use_cuda, + 'snake_agent_enabled': self.snake_agent_enabled, + 'snake_agent_interval': self.snake_agent_interval, + 'shutdown_timeout': self.shutdown_timeout, + 'graceful_shutdown_enabled': self.graceful_shutdown_enabled, + 'blog_enabled': self.blog_enabled, + 'blog_api_url': self.blog_api_url, + 'conversational_ai_enabled': self.conversational_ai_enabled, + 'data_collection_interval': self.data_collection_interval, + 'event_detection_interval': self.event_detection_interval, + 'knowledge_compression_interval': self.knowledge_compression_interval, + 'persona_name': self.persona_name, + 'persona_creativity': self.persona_creativity + } + + def save_to_file(self, filepath: str) -> None: + """Save configuration to a JSON file.""" + config_dict = self.get_config_dict() + with open(filepath, 'w', encoding='utf-8') as f: + json.dump(config_dict, f, indent=2) + + def load_from_file(self, filepath: str) -> None: + """Load configuration from a JSON file.""" + with open(filepath, 'r', encoding='utf-8') as f: + config_dict = json.load(f) + + # Update instance attributes from the loaded config + for key, value in config_dict.items(): + if hasattr(self, key): + setattr(self, key, value) + + def validate(self) -> tuple[bool, list]: + """Validate the configuration and return (is_valid, list_of_errors).""" + errors = [] + + # Validate ranges for numeric values + try: + if not 0 <= self.curiosity_chance <= 1: + errors.append("CURIOSITY_CHANCE must be between 0 and 1") + if not 0 <= self.reflection_chance <= 1: + errors.append("REFLECTION_CHANCE must be between 0 and 1") + if self.loop_sleep_duration < 0: + errors.append("LOOP_SLEEP_DURATION must be non-negative") + if self.max_iterations <= 0: + errors.append("MAX_ITERATIONS must be positive") + except (TypeError, ValueError): + errors.append("Some configuration values have incorrect types") + + # Validate primary model structure + if not isinstance(self.primary_model, dict): + errors.append("PRIMARY_MODEL must be a dictionary") + else: + required_model_keys = ['model_name', 'base_url', 'temperature'] + for key in required_model_keys: + if key not in self.primary_model: + errors.append(f"PRIMARY_MODEL missing required key: {key}") + + return len(errors) == 0, errors + + +# Singleton instance for global access +_simple_config_instance = None + + +def get_config() -> SimpleConfig: + """Get the singleton configuration instance.""" + global _simple_config_instance + if _simple_config_instance is None: + _simple_config_instance = SimpleConfig() + return _simple_config_instance \ No newline at end of file diff --git a/migrate_config.py b/migrate_config.py new file mode 100644 index 0000000..2723718 --- /dev/null +++ b/migrate_config.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python3 +""" +Configuration Migration Script for RAVANA AGI + +This script helps migrate from the complex old configuration system +to the simplified configuration system. +""" + +import json +import os +from pathlib import Path + + +def migrate_from_old_to_new(): + """ + Migrate configuration from old complex system to simplified system. + """ + print("Starting RAVANA AGI configuration migration...") + + # Try to load the old configuration files + old_core_config_path = Path("core/config.json") + old_python_config_path = Path("core/config.py") + + migrated_config = { + "system": { + "name": "RAVANA", + "database_url": "sqlite:///ravana_agi.db", + "log_level": "INFO" + }, + "operational": { + "curiosity_chance": 0.4, + "reflection_chance": 0.15, + "loop_sleep_duration": 7, + "max_iterations": 15 + }, + "models": { + "primary": { + "provider": "ollama", + "model_name": "llama3.1:8b", + "base_url": "http://localhost:11434", + "temperature": 0.7, + "max_tokens": 2048, + "timeout": 300 + } + }, + "api_keys": { + "electronhub": "ek-sVvxMYfdFQ0Kl6Aj2tmV7b8n5v0Y0sDHVsOUZWyx2vbs0AbuAc", + "zuki": "985160dfa1fd499fd12af708d16552e37a8c6f77cbfb50ae400e3ff33fbd791bc7b3b82625379a1f5ca7568f1ee04eb81a0f8c06f0ba6c276d3dddfe13e9c18d", + "gemini": "AIzaSyBW-aVU-x7JCjBJVVKjPGUacups0-GBHvQ" + }, + "memory": { + "embedding_model": "all-MiniLM-L6-v2", + "embedding_use_cuda": True + }, + "agents": { + "snake_agent": { + "enabled": True, + "interval": 180 + } + }, + "services": { + "blog": { + "enabled": True, + "api_url": "https://ravana-blog.netlify.app/api/publish" + }, + "conversational_ai": { + "enabled": True + } + }, + "scheduling": { + "data_collection_interval": 1800, + "event_detection_interval": 300, + "knowledge_compression_interval": 7200 + }, + "persona": { + "name": "Ravana", + "creativity": 0.7 + }, + "shutdown": { + "timeout": 30, + "graceful_shutdown_enabled": True + } + } + + # If old config.json exists, try to extract key values + if old_core_config_path.exists(): + print(f"Found old configuration file: {old_core_config_path}") + try: + with open(old_core_config_path, 'r', encoding='utf-8') as f: + old_config = json.load(f) + + # Extract API keys from old config + if 'electronhub' in old_config and 'api_key' in old_config['electronhub']: + migrated_config['api_keys']['electronhub'] = old_config['electronhub']['api_key'] + if 'zuki' in old_config and 'api_key' in old_config['zuki']: + migrated_config['api_keys']['zuki'] = old_config['zuki']['api_key'] + if 'gemini' in old_config and 'api_keys' in old_config['gemini']: + if isinstance(old_config['gemini']['api_keys'], list) and len(old_config['gemini']['api_keys']) > 0: + migrated_config['api_keys']['gemini'] = old_config['gemini']['api_keys'][0]['key'] + + print("Successfully extracted API keys from old configuration") + except Exception as e: + print(f"Warning: Could not read old config.json: {e}") + + # Write the new simplified configuration + new_config_path = Path("simple_config.json") + with open(new_config_path, 'w', encoding='utf-8') as f: + json.dump(migrated_config, f, indent=2) + + print(f"Migration completed! New configuration saved to {new_config_path}") + print("\nTo use the new simplified configuration:") + print("1. Update imports to use core.simple_config instead of core.config") + print("2. Use the new configuration structure as described in SIMPLIFIED_CONFIG_GUIDE.md") + print("3. The new config supports all the same environment variables as before") + + +if __name__ == "__main__": + migrate_from_old_to_new() \ No newline at end of file diff --git a/simple_config.json b/simple_config.json new file mode 100644 index 0000000..8ce7745 --- /dev/null +++ b/simple_config.json @@ -0,0 +1,60 @@ +{ + "system": { + "name": "RAVANA", + "database_url": "sqlite:///ravana_agi.db", + "log_level": "INFO" + }, + "operational": { + "curiosity_chance": 0.4, + "reflection_chance": 0.15, + "loop_sleep_duration": 7, + "max_iterations": 15 + }, + "models": { + "primary": { + "provider": "ollama", + "model_name": "llama3.1:8b", + "base_url": "http://localhost:11434", + "temperature": 0.7, + "max_tokens": 2048, + "timeout": 300 + } + }, + "api_keys": { + "electronhub": "ek-sVvxMYfdFQ0Kl6Aj2tmV7b8n5v0Y0sDHVsOUZWyx2vbs0AbuAc", + "zuki": "985160dfa1fd499fd12af708d16552e37a8c6f77cbfb50ae400e3ff33fbd791bc7b3b82625379a1f5ca7568f1ee04eb81a0f8c06f0ba6c276d3dddfe13e9c18d", + "gemini": "AIzaSyBW-aVU-x7JCjBJVVKjPGUacups0-GBHvQ" + }, + "memory": { + "embedding_model": "all-MiniLM-L6-v2", + "embedding_use_cuda": true + }, + "agents": { + "snake_agent": { + "enabled": true, + "interval": 180 + } + }, + "services": { + "blog": { + "enabled": true, + "api_url": "https://ravana-blog.netlify.app/api/publish" + }, + "conversational_ai": { + "enabled": true + } + }, + "scheduling": { + "data_collection_interval": 1800, + "event_detection_interval": 300, + "knowledge_compression_interval": 7200 + }, + "persona": { + "name": "Ravana", + "creativity": 0.7 + }, + "shutdown": { + "timeout": 30, + "graceful_shutdown_enabled": true + } +} \ No newline at end of file