prelington commited on
Commit
6fc36ee
·
verified ·
1 Parent(s): 0f65a73

Create setup_and_run.sh

Browse files
Files changed (1) hide show
  1. setup_and_run.sh +45 -0
setup_and_run.sh ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ echo "==> Setting up Python environment and dependencies..."
5
+
6
+ # check for python3
7
+ if ! command -v python3 &> /dev/null; then
8
+ echo "Python3 not found. Please install Python3.11+"
9
+ exit 1
10
+ fi
11
+
12
+ # create virtual environment
13
+ python3 -m venv .venv
14
+ source .venv/bin/activate
15
+
16
+ # upgrade pip
17
+ pip install --upgrade pip
18
+
19
+ # install requirements
20
+ cat > requirements.txt <<EOF
21
+ fastapi==0.95.2
22
+ uvicorn[standard]==0.21.1
23
+ httpx==0.24.1
24
+ python-dotenv==1.0.0
25
+ transformers==4.36.0
26
+ torch==2.2.0
27
+ python-multipart==0.0.6
28
+ sqlalchemy==2.0.19
29
+ pydantic==1.10.12
30
+ EOF
31
+
32
+ pip install -r requirements.txt
33
+
34
+ echo "==> Creating default environment variables..."
35
+ export HF_API_TOKEN=${HF_API_TOKEN:-"hf_demo_token_replace_me"}
36
+ export HF_MODEL_ID=${HF_MODEL_ID:-"gpt2"}
37
+ export RUN_MODE=${RUN_MODE:-"inference_api"}
38
+ export COGNITO_API_KEY=${COGNITO_API_KEY:-"supersecretkey123"}
39
+
40
+ echo "==> Downloading server files..."
41
+ curl -fsSL https://raw.githubusercontent.com/yourusername/cognito/main/app.py -o app.py
42
+ curl -fsSL https://raw.githubusercontent.com/yourusername/cognito/main/cognito-widget.js -o cognito-widget.js
43
+
44
+ echo "==> Starting Cognito server..."
45
+ uvicorn app:app --host 0.0.0.0 --port 8000 --reload