-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·90 lines (78 loc) · 2.9 KB
/
run.sh
File metadata and controls
executable file
·90 lines (78 loc) · 2.9 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
#!/bin/bash
# Script to run the Fact Classification API + Frontend
set -e
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$PROJECT_DIR"
echo "🚀 Starting Fact Classification System..."
echo ""
# Check if port 8000 is already in use
if command -v lsof > /dev/null 2>&1; then
if lsof -Pi :8000 -sTCP:LISTEN -t >/dev/null 2>&1; then
echo "⚠️ Warning: Port 8000 is already in use."
echo " Another instance may be running."
echo " Kill it with: kill \$(lsof -t -i:8000)"
echo ""
read -p " Continue anyway? (y/n) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "❌ Aborted"
exit 1
fi
fi
fi
# Check if virtual environment exists
if [ ! -d "venv" ]; then
echo "❌ Virtual environment not found!"
echo " Creating virtual environment..."
python3 -m venv venv
if [ $? -ne 0 ]; then
echo "❌ Failed to create virtual environment"
echo " Please ensure Python 3.9+ is installed"
exit 1
fi
echo "✓ Virtual environment created"
fi
# Activate virtual environment
echo "✓ Activating virtual environment..."
source venv/bin/activate
# Upgrade pip and install dependencies
echo "✓ Checking dependencies..."
pip install --upgrade pip -q
pip install -r requirements.txt -q
if [ $? -ne 0 ]; then
echo "❌ Failed to install dependencies"
echo " Please check requirements.txt and try again"
exit 1
fi
# Check if Knowledge Base exists
if [ ! -f "data/faiss_index/wikipedia.index" ]; then
echo ""
echo "⚠️ Knowledge Base not found!"
echo " Building KB (this will take 2-5 minutes)..."
echo ""
python scripts/build_kb.py
if [ $? -ne 0 ]; then
echo "❌ Failed to build Knowledge Base"
echo " Please check the error message above"
exit 1
fi
echo ""
echo "✓ Knowledge Base built successfully"
else
echo "✓ Knowledge Base found"
fi
# Start the server
echo ""
echo "════════════════════════════════════════════════════════════"
echo " Starting FastAPI server..."
echo "════════════════════════════════════════════════════════════"
echo ""
echo " 📡 API Docs: http://localhost:8000/docs"
echo " 🌐 Web UI: http://localhost:8000"
echo " ❤️ Health Check: http://localhost:8000/api/v1/health"
echo ""
echo " Models will load in 5-10 seconds (first request)"
echo " Press CTRL+C to stop"
echo "════════════════════════════════════════════════════════════"
echo ""
uvicorn app.main:app --host 0.0.0.0 --port 8000