Spaces:
Runtime error
Runtime error
| # Atlas Unified Platform Installation Script | |
| # This script installs all components needed for Atlas Intelligence Platform | |
| # Terminal colors | |
| CYAN='\033[0;36m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[0;33m' | |
| RED='\033[0;31m' | |
| RESET='\033[0m' | |
| # Utility functions | |
| log() { | |
| echo -e "${CYAN}[INFO]${RESET} $1" | |
| } | |
| log_success() { | |
| echo -e "${GREEN}[SUCCESS]${RESET} $1" | |
| } | |
| log_warning() { | |
| echo -e "${YELLOW}[WARNING]${RESET} $1" | |
| } | |
| log_error() { | |
| echo -e "${RED}[ERROR]${RESET} $1" | |
| } | |
| check_command() { | |
| if ! command -v "$1" &> /dev/null; then | |
| log_error "$1 could not be found. Please install it first." | |
| return 1 | |
| fi | |
| return 0 | |
| } | |
| # Base directory | |
| BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| # Modified to use actual directory paths as seen in the workspace structure | |
| PARENT_DIR_OM="/Users/lattm" | |
| PARENT_DIR_OTHERS="/Users/lattm" | |
| PARENT_DIR_CLOUD="/Users/lattm/Library/Mobile Documents/com~apple~CloudDocs/Atlas Business" | |
| # Check required tools | |
| check_command "python3" || exit 1 | |
| check_command "pip3" || exit 1 | |
| check_command "node" || exit 1 | |
| check_command "npm" || exit 1 | |
| # Create logs directory | |
| mkdir -p "$BASE_DIR/logs" | |
| mkdir -p "$BASE_DIR/pids" | |
| # Function to install OpenManus | |
| install_openmanus() { | |
| log "Installing OpenManus..." | |
| OPENMANUS_DIR="$PARENT_DIR_OM/OpenManus" | |
| # Check if directory exists | |
| if [ ! -d "$OPENMANUS_DIR" ]; then | |
| log_error "OpenManus directory not found at: $OPENMANUS_DIR" | |
| return 1 | |
| fi | |
| cd "$OPENMANUS_DIR" || exit | |
| # Create and activate virtual environment if it doesn't exist | |
| if [ ! -d "openmanus_env" ]; then | |
| python3 -m venv openmanus_env | |
| fi | |
| source openmanus_env/bin/activate | |
| # Install dependencies | |
| pip install -r requirements.txt | |
| pip install -e . | |
| # Additional dependencies for MCP server | |
| pip install fastapi uvicorn pydantic typing-extensions | |
| log_success "OpenManus installation completed" | |
| # Deactivate virtual environment | |
| deactivate | |
| } | |
| # Function to install Casibase | |
| install_casibase() { | |
| log "Installing Casibase..." | |
| CASIBASE_DIR="$PARENT_DIR_OTHERS/casibase" | |
| # Check if directory exists | |
| if [ ! -d "$CASIBASE_DIR" ]; then | |
| log_error "Casibase directory not found at: $CASIBASE_DIR" | |
| return 1 | |
| fi | |
| cd "$CASIBASE_DIR" || exit | |
| # Build Casibase if server doesn't exist | |
| if [ ! -f "./server" ]; then | |
| ./build.sh | |
| fi | |
| log_success "Casibase installation completed" | |
| } | |
| # Function to install Cypher | |
| install_cypher() { | |
| log "Installing Cypher..." | |
| CYPHER_DIR="$PARENT_DIR_OTHERS/Cypher" | |
| # Check if directory exists | |
| if [ ! -d "$CYPHER_DIR" ]; then | |
| log_error "Cypher directory not found at: $CYPHER_DIR" | |
| return 1 | |
| fi | |
| cd "$CYPHER_DIR" || exit | |
| # Install Python dependencies | |
| pip3 install -r requirements.txt | |
| log_success "Cypher installation completed" | |
| } | |
| # Function to install QuantumVision | |
| install_quantumvision() { | |
| log "Installing QuantumVision..." | |
| QUANTUM_DIR="$BASE_DIR" | |
| cd "$QUANTUM_DIR" || exit | |
| # Install Python dependencies | |
| pip3 install -r requirements.txt | |
| # Install additional dependencies | |
| pip3 install fastapi uvicorn pydantic typing-extensions openai langchain transformers torch numpy pandas scikit-learn matplotlib seaborn | |
| log_success "QuantumVision installation completed" | |
| } | |
| # Function to install AIConversationCompanion | |
| install_conversation_companion() { | |
| log "Installing AIConversationCompanion..." | |
| CONVERSATION_DIR="$PARENT_DIR_CLOUD/AIConversationCompanion" | |
| # Make sure directory exists | |
| if [ ! -d "$CONVERSATION_DIR" ]; then | |
| log_error "AIConversationCompanion directory not found at: $CONVERSATION_DIR" | |
| return 1 | |
| fi | |
| cd "$CONVERSATION_DIR" || exit | |
| # Install server dependencies | |
| cd ./server || exit | |
| npm install | |
| # Install client dependencies | |
| cd ../client || exit | |
| npm install | |
| cd "$CONVERSATION_DIR" || exit | |
| log_success "AIConversationCompanion installation completed" | |
| return 0 | |
| } | |
| # Function to install Atlas Unified Bridge | |
| install_unified_bridge() { | |
| log "Installing Atlas Unified Bridge..." | |
| BRIDGE_DIR="$BASE_DIR/atlas_bridge" | |
| # Create bridge directory if not exists | |
| mkdir -p "$BRIDGE_DIR" | |
| cd "$BRIDGE_DIR" || exit | |
| # Create bridge server file | |
| cat > bridge_server.py << 'EOL' | |
| #!/usr/bin/env python3 | |
| """ | |
| Atlas Unified Bridge Server | |
| This server connects all Atlas platform components together | |
| """ | |
| import os | |
| import sys | |
| import json | |
| import time | |
| import logging | |
| import requests | |
| from fastapi import FastAPI, HTTPException, Request | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from fastapi.responses import JSONResponse | |
| import uvicorn | |
| from pydantic import BaseModel | |
| from typing import Dict, List, Any, Optional | |
| # Setup logging | |
| logging.basicConfig( | |
| level=logging.INFO, | |
| format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', | |
| handlers=[ | |
| logging.StreamHandler(), | |
| logging.FileHandler("bridge_server.log") | |
| ] | |
| ) | |
| logger = logging.getLogger("atlas_bridge") | |
| # Component endpoints | |
| OPENMANUS_ENDPOINT = "http://localhost:50505" | |
| CASIBASE_ENDPOINT = "http://localhost:7777" | |
| CYPHER_ENDPOINT = "http://localhost:5000" | |
| QUANTUMVISION_ENDPOINT = "http://localhost:8000" | |
| CONVERSATION_ENDPOINT = "http://localhost:8001" | |
| # Initialize FastAPI app | |
| app = FastAPI(title="Atlas Unified Bridge") | |
| # Add CORS middleware | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], # Adjust in production | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| # Health check endpoint | |
| @app.get("/health") | |
| async def health_check(): | |
| """Health check endpoint to verify if bridge server is running""" | |
| status = { | |
| "bridge": "operational", | |
| "components": { | |
| "openmanus": check_component_health(OPENMANUS_ENDPOINT), | |
| "casibase": check_component_health(CASIBASE_ENDPOINT), | |
| "cypher": check_component_health(CYPHER_ENDPOINT), | |
| "quantumvision": check_component_health(QUANTUMVISION_ENDPOINT), | |
| "conversation": check_component_health(CONVERSATION_ENDPOINT) | |
| }, | |
| "timestamp": time.time() | |
| } | |
| return status | |
| def check_component_health(endpoint: str) -> str: | |
| """Check if a component is operational""" | |
| try: | |
| response = requests.get(f"{endpoint}/health", timeout=3) | |
| if response.status_code == 200: | |
| return "operational" | |
| except: | |
| pass | |
| return "unavailable" | |
| # Main entry point | |
| if __name__ == "__main__": | |
| logger.info("Starting Atlas Unified Bridge Server") | |
| uvicorn.run("bridge_server:app", host="0.0.0.0", port=8080, reload=True) | |
| EOL | |
| # Create requirements.txt for the bridge | |
| cat > requirements.txt << 'EOL' | |
| fastapi>=0.103.1 | |
| uvicorn>=0.23.2 | |
| requests>=2.31.0 | |
| pydantic>=2.3.0 | |
| python-multipart>=0.0.6 | |
| EOL | |
| # Install bridge dependencies | |
| pip3 install -r requirements.txt | |
| log_success "Atlas Unified Bridge installation completed" | |
| } | |
| # Create a requirements.txt file for QuantumVision if it doesn't exist | |
| create_quantum_requirements() { | |
| QUANTUM_REQ="$BASE_DIR/requirements.txt" | |
| if [ ! -f "$QUANTUM_REQ" ]; then | |
| log "Creating QuantumVision requirements file..." | |
| cat > "$QUANTUM_REQ" << 'EOL' | |
| fastapi>=0.103.1 | |
| uvicorn>=0.23.2 | |
| pydantic>=2.3.0 | |
| numpy>=1.24.0 | |
| pandas>=2.0.0 | |
| scikit-learn>=1.3.0 | |
| matplotlib>=3.7.0 | |
| seaborn>=0.12.0 | |
| torch>=2.0.0 | |
| transformers>=4.35.0 | |
| openai>=1.0.0 | |
| langchain>=0.0.267 | |
| requests>=2.31.0 | |
| python-dotenv>=1.0.0 | |
| pytest>=7.4.0 | |
| EOL | |
| log_success "Requirements file created" | |
| fi | |
| } | |
| # Main installation procedure | |
| log "Starting Atlas Unified Platform installation..." | |
| # Create requirements file for QuantumVision | |
| create_quantum_requirements | |
| # Install all components | |
| install_openmanus | |
| install_casibase | |
| install_cypher | |
| install_quantumvision | |
| install_conversation_companion | |
| install_unified_bridge | |
| # Set executable permissions | |
| chmod +x "$BASE_DIR/start_atlas.sh" | |
| chmod +x "$BASE_DIR/start_atlas_unified.sh" | |
| log_success "Atlas Unified Platform installation completed" | |
| log "You can now start the platform using: $BASE_DIR/start_atlas_unified.sh" | |
| # Log the installation | |
| date > "$BASE_DIR/install_log.txt" | |
| echo "Atlas Unified Platform installed successfully" >> "$BASE_DIR/install_log.txt" |