chore: import local project into Gitea
This commit is contained in:
346
quick_start.ps1
Normal file
346
quick_start.ps1
Normal file
@@ -0,0 +1,346 @@
|
||||
# MeetMe Bot Hybrid Setup - Quick Start Script
|
||||
# This script sets up the complete hybrid solution for Windows
|
||||
|
||||
Write-Host "🚀 MeetMe Bot Hybrid Setup - Quick Start" -ForegroundColor Green
|
||||
Write-Host "================================================" -ForegroundColor Green
|
||||
|
||||
# Check prerequisites
|
||||
Write-Host "`n📋 Checking prerequisites..." -ForegroundColor Yellow
|
||||
|
||||
# Check Node.js
|
||||
try {
|
||||
$nodeVersion = node --version 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "✅ Node.js found: $nodeVersion" -ForegroundColor Green
|
||||
} else {
|
||||
throw "Node.js not found"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "❌ Node.js not found. Please install Node.js 16+" -ForegroundColor Red
|
||||
Write-Host "Download from: https://nodejs.org/" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check Python
|
||||
try {
|
||||
$pythonVersion = python --version 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "✅ Python found: $pythonVersion" -ForegroundColor Green
|
||||
} else {
|
||||
throw "Python not found"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "❌ Python not found. Please install Python 3.8+" -ForegroundColor Red
|
||||
Write-Host "Download from: https://python.org/" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check MongoDB
|
||||
try {
|
||||
$mongoVersion = mongod --version 2>$null | Select-String "db version"
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "✅ MongoDB found: $mongoVersion" -ForegroundColor Green
|
||||
} else {
|
||||
throw "MongoDB not found"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "❌ MongoDB not found. Please install MongoDB" -ForegroundColor Red
|
||||
Write-Host "Download from: https://mongodb.com/try/download/community" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check Ollama
|
||||
try {
|
||||
$ollamaVersion = ollama --version 2>$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "✅ Ollama found: $ollamaVersion" -ForegroundColor Green
|
||||
} else {
|
||||
throw "Ollama not found"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "❌ Ollama not found. Please install Ollama" -ForegroundColor Red
|
||||
Write-Host "Download from: https://ollama.ai/" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "`n✅ All prerequisites met!" -ForegroundColor Green
|
||||
|
||||
# Phase 1: Setup Node.js Backend
|
||||
Write-Host "`n🔧 Phase 1: Setting up Node.js Backend..." -ForegroundColor Yellow
|
||||
|
||||
# Clone backend if not exists
|
||||
if (-not (Test-Path "meetme-backend-api")) {
|
||||
Write-Host "📥 Cloning MeetMe backend repository..." -ForegroundColor Cyan
|
||||
try {
|
||||
git clone https://github.com/Andyss4545/meetme-backend-api.git
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to clone repository"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "❌ Failed to clone repository. Please check your internet connection." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
cd meetme-backend-api
|
||||
} else {
|
||||
Write-Host "📁 Backend directory already exists" -ForegroundColor Cyan
|
||||
cd meetme-backend-api
|
||||
}
|
||||
|
||||
# Install dependencies
|
||||
Write-Host "📦 Installing Node.js dependencies..." -ForegroundColor Cyan
|
||||
try {
|
||||
npm install
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to install dependencies"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "❌ Failed to install Node.js dependencies" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create .env file for backend
|
||||
Write-Host "⚙️ Creating backend environment file..." -ForegroundColor Cyan
|
||||
$backendEnv = @"
|
||||
# Server Configuration
|
||||
PORT=3000
|
||||
NODE_ENV=development
|
||||
|
||||
# MongoDB Configuration
|
||||
MONGODB_URI=mongodb://localhost:27017/meetme_dev
|
||||
|
||||
# JWT Configuration
|
||||
JWT_SECRET=your_super_secret_jwt_key_here_$(Get-Random -Minimum 1000 -Maximum 9999)
|
||||
JWT_EXPIRES_IN=7d
|
||||
|
||||
# API Configuration
|
||||
API_BASE_URL=http://localhost:3000/api/v1
|
||||
CORS_ORIGIN=http://localhost:3000
|
||||
|
||||
# Bot Configuration
|
||||
BOT_RATE_LIMIT=100
|
||||
BOT_TIMEOUT=30000
|
||||
"@
|
||||
|
||||
$backendEnv | Out-File -FilePath ".env" -Encoding UTF8
|
||||
Write-Host "✅ Backend environment configured" -ForegroundColor Green
|
||||
|
||||
# Start MongoDB if not running
|
||||
Write-Host "🗄️ Starting MongoDB..." -ForegroundColor Cyan
|
||||
try {
|
||||
# Check if MongoDB is already running
|
||||
$mongoProcess = Get-Process -Name "mongod" -ErrorAction SilentlyContinue
|
||||
if (-not $mongoProcess) {
|
||||
# Create data directory if it doesn't exist
|
||||
$dataDir = "C:\data\db"
|
||||
if (-not (Test-Path $dataDir)) {
|
||||
New-Item -ItemType Directory -Path $dataDir -Force | Out-Null
|
||||
}
|
||||
|
||||
Start-Process -FilePath "mongod" -ArgumentList "--dbpath", $dataDir -WindowStyle Hidden
|
||||
Start-Sleep -Seconds 3 # Give MongoDB time to start
|
||||
} else {
|
||||
Write-Host "MongoDB is already running" -ForegroundColor Green
|
||||
}
|
||||
} catch {
|
||||
Write-Host "⚠️ Warning: Could not start MongoDB. Please start it manually." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Start backend server
|
||||
Write-Host "🚀 Starting Node.js backend server..." -ForegroundColor Cyan
|
||||
try {
|
||||
Start-Process -FilePath "npm" -ArgumentList "run", "dev" -WindowStyle Hidden
|
||||
Start-Sleep -Seconds 5 # Give server time to start
|
||||
} catch {
|
||||
Write-Host "⚠️ Warning: Could not start backend server. Please start it manually with 'npm run dev'" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Wait for backend to start
|
||||
Write-Host "⏳ Waiting for backend to start..." -ForegroundColor Yellow
|
||||
$maxAttempts = 30
|
||||
$attempt = 0
|
||||
$backendReady = $false
|
||||
|
||||
while ($attempt -lt $maxAttempts -and -not $backendReady) {
|
||||
try {
|
||||
$response = Invoke-WebRequest -Uri "http://localhost:3000/api/v1/health" -TimeoutSec 5 -ErrorAction SilentlyContinue
|
||||
if ($response.StatusCode -eq 200) {
|
||||
$backendReady = $true
|
||||
Write-Host "✅ Backend server is ready!" -ForegroundColor Green
|
||||
}
|
||||
} catch {
|
||||
$attempt++
|
||||
Write-Host "Waiting for backend... ($attempt/$maxAttempts)" -ForegroundColor Yellow
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $backendReady) {
|
||||
Write-Host "⚠️ Backend server may not be ready. Continuing anyway..." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Phase 2: Setup Python Environment
|
||||
Write-Host "`n🐍 Phase 2: Setting up Python Environment..." -ForegroundColor Yellow
|
||||
|
||||
# Go back to project root
|
||||
cd ..
|
||||
|
||||
# Create virtual environment
|
||||
Write-Host "📦 Creating Python virtual environment..." -ForegroundColor Cyan
|
||||
try {
|
||||
python -m venv venv
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to create virtual environment"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "❌ Failed to create virtual environment" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Activate virtual environment
|
||||
Write-Host "🔧 Activating virtual environment..." -ForegroundColor Cyan
|
||||
try {
|
||||
& ".\venv\Scripts\Activate.ps1"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to activate virtual environment"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "❌ Failed to activate virtual environment" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Install Python dependencies
|
||||
Write-Host "📦 Installing Python dependencies..." -ForegroundColor Cyan
|
||||
try {
|
||||
pip install -r requirements.txt
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to install Python dependencies"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "❌ Failed to install Python dependencies" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Phase 3: Setup Ollama
|
||||
Write-Host "`n🤖 Phase 3: Setting up Ollama..." -ForegroundColor Yellow
|
||||
|
||||
# Check if Ollama is running
|
||||
try {
|
||||
$ollamaResponse = Invoke-WebRequest -Uri "http://localhost:11434/api/tags" -TimeoutSec 5 -ErrorAction SilentlyContinue
|
||||
if ($ollamaResponse.StatusCode -eq 200) {
|
||||
Write-Host "✅ Ollama is running" -ForegroundColor Green
|
||||
} else {
|
||||
throw "Ollama not responding"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "⚠️ Ollama is not running. Please start it manually with 'ollama serve'" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Pull the required model
|
||||
Write-Host "📥 Pulling Ollama model..." -ForegroundColor Cyan
|
||||
try {
|
||||
ollama pull quen3
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "⚠️ Failed to pull model. You may need to pull it manually." -ForegroundColor Yellow
|
||||
} else {
|
||||
Write-Host "✅ Model pulled successfully" -ForegroundColor Green
|
||||
}
|
||||
} catch {
|
||||
Write-Host "⚠️ Could not pull model. Please pull it manually with 'ollama pull quen3'" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Phase 4: Create test user
|
||||
Write-Host "`n👤 Phase 4: Creating test user..." -ForegroundColor Yellow
|
||||
|
||||
# Create .env file for Python bots
|
||||
Write-Host "⚙️ Creating Python bot environment file..." -ForegroundColor Cyan
|
||||
$pythonEnv = @"
|
||||
# Enhanced Environment Configuration
|
||||
USE_LOCAL_API=true
|
||||
API_BASE_URL=http://localhost:3000/api/v1
|
||||
|
||||
# LOCAL API CREDENTIALS
|
||||
API_USERNAME=testuser@example.com
|
||||
API_PASSWORD=testpassword123
|
||||
|
||||
# BOT PERSONALITY CONFIGURATION
|
||||
MY_NAME=DrJones
|
||||
MY_PROFILE="water-tech geek, coffee addict"
|
||||
|
||||
# AI INTEGRATION (Ollama)
|
||||
OLLAMA_ENDPOINT=http://localhost:11434/v1/chat/completions
|
||||
OLLAMA_MODEL=quen3
|
||||
|
||||
# BOT BEHAVIOR SETTINGS
|
||||
POLL_INTERVAL=30
|
||||
MESSAGE_DELAY=60
|
||||
MAX_MESSAGES_PER_SESSION=20
|
||||
|
||||
# LOGGING CONFIGURATION
|
||||
LOG_LEVEL=INFO
|
||||
LOG_FILE=bot_activity.log
|
||||
|
||||
# SECURITY SETTINGS
|
||||
RATE_LIMIT_ENABLED=true
|
||||
MAX_REQUESTS_PER_MINUTE=100
|
||||
RETRY_ATTEMPTS=3
|
||||
TIMEOUT_SECONDS=30
|
||||
"@
|
||||
|
||||
$pythonEnv | Out-File -FilePath ".env" -Encoding UTF8
|
||||
Write-Host "✅ Python bot environment configured" -ForegroundColor Green
|
||||
|
||||
# Phase 5: Testing Setup
|
||||
Write-Host "`n🧪 Phase 5: Testing Setup..." -ForegroundColor Yellow
|
||||
|
||||
# Test backend connection
|
||||
Write-Host "🔍 Testing backend connection..." -ForegroundColor Cyan
|
||||
try {
|
||||
$healthResponse = Invoke-WebRequest -Uri "http://localhost:3000/api/v1/health" -TimeoutSec 10
|
||||
if ($healthResponse.StatusCode -eq 200) {
|
||||
Write-Host "✅ Backend connection successful" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "⚠️ Backend connection failed" -ForegroundColor Yellow
|
||||
}
|
||||
} catch {
|
||||
Write-Host "⚠️ Backend connection failed: $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Test Ollama connection
|
||||
Write-Host "🔍 Testing Ollama connection..." -ForegroundColor Cyan
|
||||
try {
|
||||
$ollamaTest = Invoke-WebRequest -Uri "http://localhost:11434/api/tags" -TimeoutSec 10
|
||||
if ($ollamaTest.StatusCode -eq 200) {
|
||||
Write-Host "✅ Ollama connection successful" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "⚠️ Ollama connection failed" -ForegroundColor Yellow
|
||||
}
|
||||
} catch {
|
||||
Write-Host "⚠️ Ollama connection failed: $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Test Python environment
|
||||
Write-Host "🔍 Testing Python environment..." -ForegroundColor Cyan
|
||||
try {
|
||||
python -c "import requests, schedule, dotenv; print('✅ Python dependencies installed')"
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "✅ Python environment ready" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "⚠️ Python environment issues" -ForegroundColor Yellow
|
||||
}
|
||||
} catch {
|
||||
Write-Host "⚠️ Python environment test failed" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Final instructions
|
||||
Write-Host "`n🎉 Setup Complete!" -ForegroundColor Green
|
||||
Write-Host "================================================" -ForegroundColor Green
|
||||
Write-Host "`n📋 Next Steps:" -ForegroundColor Yellow
|
||||
Write-Host "1. Start the ice breaker bot: python enhanced_icebreaker_bot.py" -ForegroundColor White
|
||||
Write-Host "2. Start the responder bot: python enhanced_responder_bot.py" -ForegroundColor White
|
||||
Write-Host "3. Monitor logs for any issues" -ForegroundColor White
|
||||
Write-Host "4. Check the HYBRID_SETUP_GUIDE.md for detailed instructions" -ForegroundColor White
|
||||
Write-Host "`n⚠️ Important Notes:" -ForegroundColor Yellow
|
||||
Write-Host "- Make sure MongoDB is running: mongod --dbpath C:\data\db" -ForegroundColor White
|
||||
Write-Host "- Make sure Ollama is running: ollama serve" -ForegroundColor White
|
||||
Write-Host "- Make sure the backend is running: cd meetme-backend-api && npm run dev" -ForegroundColor White
|
||||
Write-Host "`n🚀 Ready to run your MeetMe bots!" -ForegroundColor Green
|
||||
Reference in New Issue
Block a user