forked from tonycho/Awesome-Agentic-AI
52 lines
1.6 KiB
Bash
Executable File
52 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Define project root
|
|
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
VENV_DIR="$PROJECT_ROOT/venv"
|
|
REQUIREMENTS_FILE="$PROJECT_ROOT/requirements.txt"
|
|
|
|
# Colors for output
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo -e "${GREEN}🚀 Starting Agentic-AI Backend Setup...${NC}"
|
|
|
|
# 1. Check/Create Virtual Environment
|
|
if [ ! -d "$VENV_DIR" ]; then
|
|
echo -e "${YELLOW}📦 Creating virtual environment...${NC}"
|
|
python3 -m venv "$VENV_DIR"
|
|
else
|
|
echo -e "${GREEN}✅ Virtual environment found.${NC}"
|
|
fi
|
|
|
|
# 1.1 Check for System Dependencies (Tesseract)
|
|
if ! command -v tesseract &> /dev/null; then
|
|
echo -e "${YELLOW}⚠️ tesseract-ocr not found! OCR features will be disabled.${NC}"
|
|
echo -e "${YELLOW} Install it via: sudo apt-get install tesseract-ocr${NC}"
|
|
else
|
|
echo -e "${GREEN}✅ tesseract-ocr found.$(tesseract --version | head -n 1)${NC}"
|
|
fi
|
|
|
|
# 2. Activate Virtual Environment
|
|
source "$VENV_DIR/bin/activate"
|
|
|
|
# 3. Install/Update Dependencies
|
|
if [ -f "$REQUIREMENTS_FILE" ]; then
|
|
echo -e "${YELLOW}⬇️ Installing/Updating dependencies...${NC}"
|
|
pip install -r "$REQUIREMENTS_FILE"
|
|
|
|
# Check for specific troublesome packages and force reinstall if needed
|
|
# (Optional: Add specific checks here if needed)
|
|
|
|
else
|
|
echo -e "${RED}❌ requirements.txt not found!${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
# 4. Run the Backend
|
|
echo -e "${GREEN}🔥 Starting FastAPI server on 0.0.0.0:8000...${NC}"
|
|
# We use python -m uvicorn to ensure we use the venv's uvicorn
|
|
python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload
|