File size: 2,743 Bytes
2337d84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash

# Text colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'

# Function to print colored messages
print_success() {
    echo -e "${GREEN}[✔] $1${NC}"
}

print_error() {
    echo -e "${RED}[✘] $1${NC}"
}

print_warning() {
    echo -e "${YELLOW}[!] $1${NC}"
}

print_info() {
    echo -e "[*] $1"
}

# Header
echo "======================================"
echo "    BLOOM AI Setup for Hugging Face   "
echo "======================================"
echo

# Create necessary directories
print_info "Setting up project directories..."
directories=("static" "templates" "cache" "cache/torch")
for dir in "${directories[@]}"; do
    if [ ! -d "$dir" ]; then
        mkdir -p "$dir"
        chmod 777 "$dir"
        print_success "Created directory: $dir"
    else
        print_info "Directory exists: $dir"
        chmod 777 "$dir"
    fi
done

# Check required files
print_info "Checking required files..."
required_files=(
    "app.py"
    "requirements.txt"
    "Dockerfile"
    "docker-compose.yml"
    "templates/index.html"
    "README.md"
)

files_ok=true
for file in "${required_files[@]}"; do
    if [ ! -f "$file" ]; then
        print_error "Missing required file: $file"
        files_ok=false
    else
        print_success "Found $file"
    fi
done

# Create README.md if it doesn't exist
if [ ! -f "README.md" ]; then
    cat > README.md <<EOF
---
title: BLOOM AI Assistant
emoji: 🤖
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
---

# BLOOM AI Assistant

This is a FastAPI-based AI assistant using BLOOM model.
EOF
    print_success "Created README.md with Hugging Face metadata"
fi

# Check static directory content
if [ -z "$(ls -A static 2>/dev/null)" ]; then
    print_warning "Static directory is empty. Make sure to add your static files."
fi

# Set correct permissions
print_info "Setting permissions..."
chmod -R 777 cache templates static
print_success "Permissions updated"

# Create .dockerignore
cat > .dockerignore <<EOF
.git
.gitignore
README.md
*.pyc
__pycache__
.pytest_cache
.env
.venv
EOF
print_success "Created .dockerignore"

# Create .gitignore
cat > .gitignore <<EOF
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
.env
.venv
.idea/
.vscode/
cache/
logs/
EOF
print_success "Created .gitignore"

# Final status
echo
echo "======================================"
if [ "$files_ok" = true ]; then
    print_success "Setup completed successfully!"
    echo
    print_info "Ready for Hugging Face deployment"
else
    print_error "Setup completed with warnings. Please fix the issues above."
fi
echo "======================================"