#!/bin/bash # Start script for the lightweight LLM service # This script handles environment setup and service startup set -e echo "🚀 Starting Lightweight LLM with MCP Integration..." # Print configuration echo "📋 Configuration:" echo " Model: ${MODEL_NAME:-microsoft/DialoGPT-small}" echo " Port: ${PORT:-7860}" echo " MCP Server: ${MCP_SERVER_URL:-Not configured}" echo " Max Tokens: ${MAX_NEW_TOKENS:-256}" # Health check function health_check() { local max_attempts=30 local attempt=1 echo "🔍 Waiting for service to be ready..." while [ $attempt -le $max_attempts ]; do if curl -f http://localhost:${PORT:-7860}/health >/dev/null 2>&1; then echo "✅ Service is ready!" return 0 fi echo "âŗ Attempt $attempt/$max_attempts - waiting 2 seconds..." sleep 2 attempt=$((attempt + 1)) done echo "❌ Service failed to start within expected time" return 1 } # Start the application in the background echo "🔄 Starting FastAPI application..." python app.py & APP_PID=$! # Wait for the service to be ready if health_check; then echo "🎉 Lightweight LLM service is running successfully!" echo "📡 API Documentation: http://localhost:${PORT:-7860}/docs" echo "đŸĨ Health Check: http://localhost:${PORT:-7860}/health" echo "â„šī¸ Service Info: http://localhost:${PORT:-7860}/info" # Keep the script running wait $APP_PID else echo "đŸ’Ĩ Failed to start service" kill $APP_PID 2>/dev/null || true exit 1 fi