Spaces:
Runtime error
Runtime error
File size: 8,478 Bytes
8beb2b1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
#!/bin/bash
# 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" |