-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·113 lines (97 loc) · 2.76 KB
/
run.sh
File metadata and controls
executable file
·113 lines (97 loc) · 2.76 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
# AI Documentation Assistant - Run Script
echo "🤖 AI Documentation Assistant"
echo "=============================="
echo ""
# Check if .env file exists
if [ ! -f .env ]; then
echo "⚠️ No .env file found. Creating from .env.example..."
cp .env.example .env
echo "✅ Created .env file. Please update it with your API keys."
echo ""
echo "Required API keys:"
echo " - OPENAI_API_KEY"
echo " - PINECONE_API_KEY"
echo " - PINECONE_ENVIRONMENT"
echo ""
echo "After updating .env, run this script again."
exit 1
fi
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check Python version
if command_exists python3; then
PYTHON=python3
elif command_exists python; then
PYTHON=python
else
echo "❌ Python not found. Please install Python 3.9 or higher."
exit 1
fi
echo "📍 Using Python: $($PYTHON --version)"
echo ""
# Create virtual environment if it doesn't exist
if [ ! -d "venv" ]; then
echo "🔧 Creating virtual environment..."
$PYTHON -m venv venv
fi
# Activate virtual environment
echo "🔧 Activating virtual environment..."
source venv/bin/activate
# Install/upgrade pip
echo "🔧 Upgrading pip..."
pip install --upgrade pip
# Install requirements
echo "📦 Installing requirements..."
pip install -r requirements.txt
# Initialize database
echo "🗄️ Initializing database..."
python scripts/init_db.py
# Start services based on argument
case "$1" in
"api")
echo "🚀 Starting API server..."
python -m src.api.main
;;
"ui")
echo "🎨 Starting Streamlit UI..."
streamlit run src/ui/app.py
;;
"docker")
echo "🐳 Starting with Docker Compose..."
docker-compose up --build
;;
"all")
echo "🚀 Starting all services..."
# Start API in background
python -m src.api.main &
API_PID=$!
# Wait a bit for API to start
sleep 3
# Start UI
streamlit run src/ui/app.py &
UI_PID=$!
echo ""
echo "✅ Services started:"
echo " - API: http://localhost:8000"
echo " - UI: http://localhost:8501"
echo ""
echo "Press Ctrl+C to stop all services..."
# Wait for interrupt
trap "kill $API_PID $UI_PID; exit" INT
wait
;;
*)
echo "Usage: ./run.sh [api|ui|docker|all]"
echo ""
echo "Options:"
echo " api - Start only the FastAPI backend"
echo " ui - Start only the Streamlit UI"
echo " docker - Start with Docker Compose"
echo " all - Start both API and UI locally"
echo ""
echo "Example: ./run.sh all"
;;
esac