superbrain-server 1.0.48 → 1.0.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/superbrain.js +204 -204
- package/package.json +1 -1
- package/payload/.env.example +58 -58
- package/payload/Dockerfile +73 -73
- package/payload/config/model_rankings.json +16 -26
- package/payload/config/openrouter_free_models.json +1 -53
- package/payload/docker-compose.yml +124 -124
- package/payload/start-docker-prod.sh +125 -125
- package/payload/start-docker.sh +56 -56
- package/payload/stop-docker.sh +16 -16
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# ────────────────────────────────────────────────────────────────────────────────
|
|
4
|
-
# SuperBrain Backend Production Startup Script
|
|
5
|
-
# Ensures all configuration is validated and services are healthy
|
|
6
|
-
# ────────────────────────────────────────────────────────────────────────────────
|
|
7
|
-
|
|
8
|
-
set -e # Exit on any error
|
|
9
|
-
|
|
10
|
-
# Colors for output
|
|
11
|
-
RED='\033[0;31m'
|
|
12
|
-
GREEN='\033[0;32m'
|
|
13
|
-
YELLOW='\033[1;33m'
|
|
14
|
-
BLUE='\033[0;34m'
|
|
15
|
-
NC='\033[0m' # No Color
|
|
16
|
-
|
|
17
|
-
echo -e "${BLUE}╔════════════════════════════════════════════════════════════════╗${NC}"
|
|
18
|
-
echo -e "${BLUE}║ SuperBrain API - Production Startup ║${NC}"
|
|
19
|
-
echo -e "${BLUE}╚════════════════════════════════════════════════════════════════╝${NC}"
|
|
20
|
-
|
|
21
|
-
# ──── Check prerequisites ────
|
|
22
|
-
echo -e "\n${YELLOW}→ Checking prerequisites...${NC}"
|
|
23
|
-
|
|
24
|
-
if ! command -v docker &> /dev/null; then
|
|
25
|
-
echo -e "${RED}✗ Docker is not installed${NC}"
|
|
26
|
-
exit 1
|
|
27
|
-
fi
|
|
28
|
-
echo -e "${GREEN}✓ Docker found${NC}"
|
|
29
|
-
|
|
30
|
-
if docker compose version &> /dev/null; then
|
|
31
|
-
COMPOSE_CMD="docker compose"
|
|
32
|
-
elif command -v docker-compose &> /dev/null; then
|
|
33
|
-
COMPOSE_CMD="docker-compose"
|
|
34
|
-
else
|
|
35
|
-
echo -e "${RED}✗ Docker Compose is not installed${NC}"
|
|
36
|
-
exit 1
|
|
37
|
-
fi
|
|
38
|
-
echo -e "${GREEN}✓ Docker Compose found (${COMPOSE_CMD})${NC}"
|
|
39
|
-
|
|
40
|
-
# ──── Check environment file ────
|
|
41
|
-
echo -e "\n${YELLOW}→ Checking environment configuration...${NC}"
|
|
42
|
-
|
|
43
|
-
if [ ! -f .env ]; then
|
|
44
|
-
if [ -f .env.example ]; then
|
|
45
|
-
echo -e "${YELLOW}⚠ .env file not found. Creating from .env.example...${NC}"
|
|
46
|
-
cp .env.example .env
|
|
47
|
-
echo -e "${YELLOW}⚠ Please edit .env with your actual credentials and run this script again${NC}"
|
|
48
|
-
exit 1
|
|
49
|
-
else
|
|
50
|
-
echo -e "${RED}✗ Neither .env nor .env.example found${NC}"
|
|
51
|
-
exit 1
|
|
52
|
-
fi
|
|
53
|
-
else
|
|
54
|
-
echo -e "${GREEN}✓ .env file found${NC}"
|
|
55
|
-
fi
|
|
56
|
-
|
|
57
|
-
# ──── Check required API keys ────
|
|
58
|
-
source .env
|
|
59
|
-
|
|
60
|
-
if [ -z "$GROQ_API_KEY" ] && [ -z "$GEMINI_API_KEY" ] && [ -z "$GOOGLE_API_KEY" ] && [ -z "$OPENROUTER_API_KEY" ]; then
|
|
61
|
-
echo -e "${YELLOW}⚠ Warning: No AI provider API keys configured${NC}"
|
|
62
|
-
echo -e "${YELLOW} Set at least one of: GROQ_API_KEY, GEMINI_API_KEY, OPENROUTER_API_KEY${NC}"
|
|
63
|
-
fi
|
|
64
|
-
|
|
65
|
-
# ──── Create necessary directories ────
|
|
66
|
-
echo -e "\n${YELLOW}→ Setting up directories...${NC}"
|
|
67
|
-
|
|
68
|
-
mkdir -p config temp static/uploads logs
|
|
69
|
-
chmod 755 config temp static static/uploads logs
|
|
70
|
-
|
|
71
|
-
echo -e "${GREEN}✓ Directories created${NC}"
|
|
72
|
-
|
|
73
|
-
# ──── Build Docker image ────
|
|
74
|
-
echo -e "\n${YELLOW}→ Building Docker image...${NC}"
|
|
75
|
-
|
|
76
|
-
${COMPOSE_CMD} build --no-cache
|
|
77
|
-
|
|
78
|
-
echo -e "${GREEN}✓ Docker image built successfully${NC}"
|
|
79
|
-
|
|
80
|
-
# ──── Start services ────
|
|
81
|
-
echo -e "\n${YELLOW}→ Starting SuperBrain API...${NC}"
|
|
82
|
-
|
|
83
|
-
${COMPOSE_CMD} up -d
|
|
84
|
-
|
|
85
|
-
echo -e "${GREEN}✓ Containers started${NC}"
|
|
86
|
-
|
|
87
|
-
# ──── Wait for service to be healthy ────
|
|
88
|
-
echo -e "\n${YELLOW}→ Waiting for API to become healthy...${NC}"
|
|
89
|
-
|
|
90
|
-
for i in {1..30}; do
|
|
91
|
-
if ${COMPOSE_CMD} exec -T superbrain-api curl -s http://localhost:5000/health > /dev/null 2>&1; then
|
|
92
|
-
echo -e "${GREEN}✓ API is healthy${NC}"
|
|
93
|
-
break
|
|
94
|
-
fi
|
|
95
|
-
|
|
96
|
-
if [ $i -eq 30 ]; then
|
|
97
|
-
echo -e "${RED}✗ API failed to start after 30 seconds${NC}"
|
|
98
|
-
${COMPOSE_CMD} logs superbrain-api
|
|
99
|
-
exit 1
|
|
100
|
-
fi
|
|
101
|
-
|
|
102
|
-
echo -n "."
|
|
103
|
-
sleep 1
|
|
104
|
-
done
|
|
105
|
-
|
|
106
|
-
# ──── Display status ────
|
|
107
|
-
echo -e "\n${BLUE}╔════════════════════════════════════════════════════════════════╗${NC}"
|
|
108
|
-
echo -e "${BLUE}║ Startup Complete! ✓ ║${NC}"
|
|
109
|
-
echo -e "${BLUE}╚════════════════════════════════════════════════════════════════╝${NC}"
|
|
110
|
-
|
|
111
|
-
echo -e "\n${GREEN}Services running:${NC}"
|
|
112
|
-
${COMPOSE_CMD} ps
|
|
113
|
-
|
|
114
|
-
echo -e "\n${GREEN}API Information:${NC}"
|
|
115
|
-
echo -e " 📡 Endpoint: http://localhost:${API_PORT:-5000}"
|
|
116
|
-
echo -e " 📚 Documentation: http://localhost:${API_PORT:-5000}/docs"
|
|
117
|
-
echo -e " 🏥 Health Check: http://localhost:${API_PORT:-5000}/health"
|
|
118
|
-
|
|
119
|
-
echo -e "\n${GREEN}Useful commands:${NC}"
|
|
120
|
-
echo -e " View logs: ${YELLOW}${COMPOSE_CMD} logs -f superbrain-api${NC}"
|
|
121
|
-
echo -e " Stop services: ${YELLOW}${COMPOSE_CMD} down${NC}"
|
|
122
|
-
echo -e " Restart: ${YELLOW}${COMPOSE_CMD} restart${NC}"
|
|
123
|
-
echo -e " Status: ${YELLOW}${COMPOSE_CMD} ps${NC}"
|
|
124
|
-
|
|
125
|
-
echo -e "\n"
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# ────────────────────────────────────────────────────────────────────────────────
|
|
4
|
+
# SuperBrain Backend Production Startup Script
|
|
5
|
+
# Ensures all configuration is validated and services are healthy
|
|
6
|
+
# ────────────────────────────────────────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
set -e # Exit on any error
|
|
9
|
+
|
|
10
|
+
# Colors for output
|
|
11
|
+
RED='\033[0;31m'
|
|
12
|
+
GREEN='\033[0;32m'
|
|
13
|
+
YELLOW='\033[1;33m'
|
|
14
|
+
BLUE='\033[0;34m'
|
|
15
|
+
NC='\033[0m' # No Color
|
|
16
|
+
|
|
17
|
+
echo -e "${BLUE}╔════════════════════════════════════════════════════════════════╗${NC}"
|
|
18
|
+
echo -e "${BLUE}║ SuperBrain API - Production Startup ║${NC}"
|
|
19
|
+
echo -e "${BLUE}╚════════════════════════════════════════════════════════════════╝${NC}"
|
|
20
|
+
|
|
21
|
+
# ──── Check prerequisites ────
|
|
22
|
+
echo -e "\n${YELLOW}→ Checking prerequisites...${NC}"
|
|
23
|
+
|
|
24
|
+
if ! command -v docker &> /dev/null; then
|
|
25
|
+
echo -e "${RED}✗ Docker is not installed${NC}"
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
echo -e "${GREEN}✓ Docker found${NC}"
|
|
29
|
+
|
|
30
|
+
if docker compose version &> /dev/null; then
|
|
31
|
+
COMPOSE_CMD="docker compose"
|
|
32
|
+
elif command -v docker-compose &> /dev/null; then
|
|
33
|
+
COMPOSE_CMD="docker-compose"
|
|
34
|
+
else
|
|
35
|
+
echo -e "${RED}✗ Docker Compose is not installed${NC}"
|
|
36
|
+
exit 1
|
|
37
|
+
fi
|
|
38
|
+
echo -e "${GREEN}✓ Docker Compose found (${COMPOSE_CMD})${NC}"
|
|
39
|
+
|
|
40
|
+
# ──── Check environment file ────
|
|
41
|
+
echo -e "\n${YELLOW}→ Checking environment configuration...${NC}"
|
|
42
|
+
|
|
43
|
+
if [ ! -f .env ]; then
|
|
44
|
+
if [ -f .env.example ]; then
|
|
45
|
+
echo -e "${YELLOW}⚠ .env file not found. Creating from .env.example...${NC}"
|
|
46
|
+
cp .env.example .env
|
|
47
|
+
echo -e "${YELLOW}⚠ Please edit .env with your actual credentials and run this script again${NC}"
|
|
48
|
+
exit 1
|
|
49
|
+
else
|
|
50
|
+
echo -e "${RED}✗ Neither .env nor .env.example found${NC}"
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
else
|
|
54
|
+
echo -e "${GREEN}✓ .env file found${NC}"
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
# ──── Check required API keys ────
|
|
58
|
+
source .env
|
|
59
|
+
|
|
60
|
+
if [ -z "$GROQ_API_KEY" ] && [ -z "$GEMINI_API_KEY" ] && [ -z "$GOOGLE_API_KEY" ] && [ -z "$OPENROUTER_API_KEY" ]; then
|
|
61
|
+
echo -e "${YELLOW}⚠ Warning: No AI provider API keys configured${NC}"
|
|
62
|
+
echo -e "${YELLOW} Set at least one of: GROQ_API_KEY, GEMINI_API_KEY, OPENROUTER_API_KEY${NC}"
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
# ──── Create necessary directories ────
|
|
66
|
+
echo -e "\n${YELLOW}→ Setting up directories...${NC}"
|
|
67
|
+
|
|
68
|
+
mkdir -p config temp static/uploads logs
|
|
69
|
+
chmod 755 config temp static static/uploads logs
|
|
70
|
+
|
|
71
|
+
echo -e "${GREEN}✓ Directories created${NC}"
|
|
72
|
+
|
|
73
|
+
# ──── Build Docker image ────
|
|
74
|
+
echo -e "\n${YELLOW}→ Building Docker image...${NC}"
|
|
75
|
+
|
|
76
|
+
${COMPOSE_CMD} build --no-cache
|
|
77
|
+
|
|
78
|
+
echo -e "${GREEN}✓ Docker image built successfully${NC}"
|
|
79
|
+
|
|
80
|
+
# ──── Start services ────
|
|
81
|
+
echo -e "\n${YELLOW}→ Starting SuperBrain API...${NC}"
|
|
82
|
+
|
|
83
|
+
${COMPOSE_CMD} up -d
|
|
84
|
+
|
|
85
|
+
echo -e "${GREEN}✓ Containers started${NC}"
|
|
86
|
+
|
|
87
|
+
# ──── Wait for service to be healthy ────
|
|
88
|
+
echo -e "\n${YELLOW}→ Waiting for API to become healthy...${NC}"
|
|
89
|
+
|
|
90
|
+
for i in {1..30}; do
|
|
91
|
+
if ${COMPOSE_CMD} exec -T superbrain-api curl -s http://localhost:5000/health > /dev/null 2>&1; then
|
|
92
|
+
echo -e "${GREEN}✓ API is healthy${NC}"
|
|
93
|
+
break
|
|
94
|
+
fi
|
|
95
|
+
|
|
96
|
+
if [ $i -eq 30 ]; then
|
|
97
|
+
echo -e "${RED}✗ API failed to start after 30 seconds${NC}"
|
|
98
|
+
${COMPOSE_CMD} logs superbrain-api
|
|
99
|
+
exit 1
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
echo -n "."
|
|
103
|
+
sleep 1
|
|
104
|
+
done
|
|
105
|
+
|
|
106
|
+
# ──── Display status ────
|
|
107
|
+
echo -e "\n${BLUE}╔════════════════════════════════════════════════════════════════╗${NC}"
|
|
108
|
+
echo -e "${BLUE}║ Startup Complete! ✓ ║${NC}"
|
|
109
|
+
echo -e "${BLUE}╚════════════════════════════════════════════════════════════════╝${NC}"
|
|
110
|
+
|
|
111
|
+
echo -e "\n${GREEN}Services running:${NC}"
|
|
112
|
+
${COMPOSE_CMD} ps
|
|
113
|
+
|
|
114
|
+
echo -e "\n${GREEN}API Information:${NC}"
|
|
115
|
+
echo -e " 📡 Endpoint: http://localhost:${API_PORT:-5000}"
|
|
116
|
+
echo -e " 📚 Documentation: http://localhost:${API_PORT:-5000}/docs"
|
|
117
|
+
echo -e " 🏥 Health Check: http://localhost:${API_PORT:-5000}/health"
|
|
118
|
+
|
|
119
|
+
echo -e "\n${GREEN}Useful commands:${NC}"
|
|
120
|
+
echo -e " View logs: ${YELLOW}${COMPOSE_CMD} logs -f superbrain-api${NC}"
|
|
121
|
+
echo -e " Stop services: ${YELLOW}${COMPOSE_CMD} down${NC}"
|
|
122
|
+
echo -e " Restart: ${YELLOW}${COMPOSE_CMD} restart${NC}"
|
|
123
|
+
echo -e " Status: ${YELLOW}${COMPOSE_CMD} ps${NC}"
|
|
124
|
+
|
|
125
|
+
echo -e "\n"
|
package/payload/start-docker.sh
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# SuperBrain Docker Setup Script
|
|
4
|
-
# One-click script to build and start the SuperBrain backend
|
|
5
|
-
|
|
6
|
-
set -e
|
|
7
|
-
|
|
8
|
-
echo "🐳 SuperBrain Docker Setup"
|
|
9
|
-
echo "=========================="
|
|
10
|
-
|
|
11
|
-
# Check if Docker is installed
|
|
12
|
-
if ! command -v docker &> /dev/null; then
|
|
13
|
-
echo "❌ Docker is not installed. Please install Docker first."
|
|
14
|
-
exit 1
|
|
15
|
-
fi
|
|
16
|
-
|
|
17
|
-
# Check if docker-compose or docker compose is available
|
|
18
|
-
if ! command -v docker compose &> /dev/null && ! command -v docker-compose &> /dev/null; then
|
|
19
|
-
echo "❌ Docker Compose is not installed. Please install Docker Compose first."
|
|
20
|
-
exit 1
|
|
21
|
-
fi
|
|
22
|
-
|
|
23
|
-
# Use docker compose if available, otherwise docker-compose
|
|
24
|
-
if command -v docker compose &> /dev/null; then
|
|
25
|
-
DOCKER_COMPOSE="docker compose"
|
|
26
|
-
else
|
|
27
|
-
DOCKER_COMPOSE="docker-compose"
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
# Check if .env exists, if not create from example
|
|
31
|
-
if [ ! -f .env ]; then
|
|
32
|
-
echo "📝 Creating .env file from example..."
|
|
33
|
-
if [ -f .env.example ]; then
|
|
34
|
-
cp .env.example .env
|
|
35
|
-
echo "✅ Created .env file. Please edit it with your API keys."
|
|
36
|
-
else
|
|
37
|
-
echo "⚠️ No .env.example found, continuing without environment variables."
|
|
38
|
-
fi
|
|
39
|
-
fi
|
|
40
|
-
|
|
41
|
-
# Build and start the container
|
|
42
|
-
echo "🔨 Building Docker image..."
|
|
43
|
-
$DOCKER_COMPOSE build
|
|
44
|
-
|
|
45
|
-
echo "🚀 Starting SuperBrain..."
|
|
46
|
-
$DOCKER_COMPOSE up -d
|
|
47
|
-
|
|
48
|
-
echo ""
|
|
49
|
-
echo "✅ SuperBrain is now running!"
|
|
50
|
-
echo "📖 API: http://localhost:5000"
|
|
51
|
-
echo "📚 Docs: http://localhost:5000/docs"
|
|
52
|
-
echo ""
|
|
53
|
-
echo "Useful commands:"
|
|
54
|
-
echo " $DOCKER_COMPOSE logs -f # View logs"
|
|
55
|
-
echo " $DOCKER_COMPOSE down # Stop the server"
|
|
56
|
-
echo " $DOCKER_COMPOSE restart # Restart the server"
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# SuperBrain Docker Setup Script
|
|
4
|
+
# One-click script to build and start the SuperBrain backend
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
echo "🐳 SuperBrain Docker Setup"
|
|
9
|
+
echo "=========================="
|
|
10
|
+
|
|
11
|
+
# Check if Docker is installed
|
|
12
|
+
if ! command -v docker &> /dev/null; then
|
|
13
|
+
echo "❌ Docker is not installed. Please install Docker first."
|
|
14
|
+
exit 1
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
# Check if docker-compose or docker compose is available
|
|
18
|
+
if ! command -v docker compose &> /dev/null && ! command -v docker-compose &> /dev/null; then
|
|
19
|
+
echo "❌ Docker Compose is not installed. Please install Docker Compose first."
|
|
20
|
+
exit 1
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# Use docker compose if available, otherwise docker-compose
|
|
24
|
+
if command -v docker compose &> /dev/null; then
|
|
25
|
+
DOCKER_COMPOSE="docker compose"
|
|
26
|
+
else
|
|
27
|
+
DOCKER_COMPOSE="docker-compose"
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
# Check if .env exists, if not create from example
|
|
31
|
+
if [ ! -f .env ]; then
|
|
32
|
+
echo "📝 Creating .env file from example..."
|
|
33
|
+
if [ -f .env.example ]; then
|
|
34
|
+
cp .env.example .env
|
|
35
|
+
echo "✅ Created .env file. Please edit it with your API keys."
|
|
36
|
+
else
|
|
37
|
+
echo "⚠️ No .env.example found, continuing without environment variables."
|
|
38
|
+
fi
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# Build and start the container
|
|
42
|
+
echo "🔨 Building Docker image..."
|
|
43
|
+
$DOCKER_COMPOSE build
|
|
44
|
+
|
|
45
|
+
echo "🚀 Starting SuperBrain..."
|
|
46
|
+
$DOCKER_COMPOSE up -d
|
|
47
|
+
|
|
48
|
+
echo ""
|
|
49
|
+
echo "✅ SuperBrain is now running!"
|
|
50
|
+
echo "📖 API: http://localhost:5000"
|
|
51
|
+
echo "📚 Docs: http://localhost:5000/docs"
|
|
52
|
+
echo ""
|
|
53
|
+
echo "Useful commands:"
|
|
54
|
+
echo " $DOCKER_COMPOSE logs -f # View logs"
|
|
55
|
+
echo " $DOCKER_COMPOSE down # Stop the server"
|
|
56
|
+
echo " $DOCKER_COMPOSE restart # Restart the server"
|
package/payload/stop-docker.sh
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# SuperBrain Docker Stop Script
|
|
4
|
-
|
|
5
|
-
echo "🛑 Stopping SuperBrain..."
|
|
6
|
-
|
|
7
|
-
# Use docker compose if available, otherwise docker-compose
|
|
8
|
-
if command -v docker compose &> /dev/null; then
|
|
9
|
-
DOCKER_COMPOSE="docker compose"
|
|
10
|
-
else
|
|
11
|
-
DOCKER_COMPOSE="docker-compose"
|
|
12
|
-
fi
|
|
13
|
-
|
|
14
|
-
$DOCKER_COMPOSE down
|
|
15
|
-
|
|
16
|
-
echo "✅ SuperBrain stopped."
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# SuperBrain Docker Stop Script
|
|
4
|
+
|
|
5
|
+
echo "🛑 Stopping SuperBrain..."
|
|
6
|
+
|
|
7
|
+
# Use docker compose if available, otherwise docker-compose
|
|
8
|
+
if command -v docker compose &> /dev/null; then
|
|
9
|
+
DOCKER_COMPOSE="docker compose"
|
|
10
|
+
else
|
|
11
|
+
DOCKER_COMPOSE="docker-compose"
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
$DOCKER_COMPOSE down
|
|
15
|
+
|
|
16
|
+
echo "✅ SuperBrain stopped."
|