File size: 1,585 Bytes
e02dee9 | 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 | #!/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
|