aiagent / start.sh
jdewitte's picture
First deployment of complete llm
e02dee9
Raw
History Blame Contribute Delete
1.59 kB
#!/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