|
#!/bin/bash |
|
|
|
|
|
|
|
set -e |
|
|
|
|
|
if [ -f .env ]; then |
|
export $(cat .env | grep -v '^#' | xargs) |
|
fi |
|
|
|
|
|
RED='\033[0;31m' |
|
GREEN='\033[0;32m' |
|
YELLOW='\033[1;33m' |
|
BLUE='\033[0;34m' |
|
NC='\033[0m' |
|
|
|
print_status() { |
|
echo -e "${BLUE}[INFO]${NC} $1" |
|
} |
|
|
|
print_success() { |
|
echo -e "${GREEN}[SUCCESS]${NC} $1" |
|
} |
|
|
|
print_warning() { |
|
echo -e "${YELLOW}[WARNING]${NC} $1" |
|
} |
|
|
|
print_error() { |
|
echo -e "${RED}[ERROR]${NC} $1" |
|
} |
|
|
|
|
|
create_github_repo() { |
|
local repo_name=${1:-"gpt-local"} |
|
local description="🤖 Sistema de chat GPT local con Hugging Face - Soporte Docker, CLI y múltiples modelos" |
|
|
|
print_status "Creando repositorio en GitHub: $repo_name" |
|
|
|
|
|
if ! gh auth status &> /dev/null; then |
|
print_error "GitHub CLI no está autenticado" |
|
print_status "Ejecuta: gh auth login --with-token" |
|
return 1 |
|
fi |
|
|
|
|
|
if gh repo create "$repo_name" --description "$description" --public --clone=false; then |
|
print_success "Repositorio '$repo_name' creado en GitHub" |
|
|
|
|
|
if git remote | grep -q "origin"; then |
|
git remote set-url origin "https://github.com/$(gh api user --jq .login)/$repo_name.git" |
|
else |
|
git remote add origin "https://github.com/$(gh api user --jq .login)/$repo_name.git" |
|
fi |
|
|
|
print_success "Remoto configurado" |
|
return 0 |
|
else |
|
print_warning "El repositorio puede ya existir o hubo un error" |
|
return 1 |
|
fi |
|
} |
|
|
|
|
|
create_huggingface_repo() { |
|
local repo_name=${1:-"gpt-local"} |
|
local repo_type=${2:-"space"} |
|
|
|
print_status "Creando repositorio en Hugging Face: $repo_name" |
|
|
|
|
|
if [ -z "$HUGGINGFACE_TOKEN" ]; then |
|
print_error "Token de Hugging Face no configurado" |
|
print_status "Configura HUGGINGFACE_TOKEN en .env" |
|
return 1 |
|
fi |
|
|
|
|
|
case $repo_type in |
|
"space") |
|
print_status "Creando Hugging Face Space..." |
|
if huggingface-cli upload . . --repo-id "$(huggingface-cli whoami | head -1)/$repo_name" --repo-type space --create; then |
|
print_success "Hugging Face Space creado: https://huggingface.co/spaces/$(huggingface-cli whoami | head -1)/$repo_name" |
|
else |
|
print_warning "Error creando Space o ya existe" |
|
fi |
|
;; |
|
"model") |
|
print_status "Creando repositorio de modelo..." |
|
|
|
;; |
|
"dataset") |
|
print_status "Creando repositorio de dataset..." |
|
|
|
;; |
|
esac |
|
} |
|
|
|
|
|
setup_git() { |
|
print_status "Configurando Git..." |
|
|
|
|
|
if [ ! -d ".git" ]; then |
|
git init |
|
print_success "Repositorio Git inicializado" |
|
fi |
|
|
|
|
|
if [ ! -f ".gitignore" ]; then |
|
cat > .gitignore << 'EOF' |
|
|
|
.env |
|
*.token |
|
.cache/ |
|
.secrets/ |
|
|
|
|
|
__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 |
|
|
|
|
|
models_cache/ |
|
models/*/ |
|
*.bin |
|
*.safetensors |
|
.cache/ |
|
huggingface_cache/ |
|
|
|
|
|
*.log |
|
logs/ |
|
.logs/ |
|
|
|
|
|
.DS_Store |
|
.DS_Store? |
|
._* |
|
.Spotlight-V100 |
|
.Trashes |
|
ehthumbs.db |
|
Thumbs.db |
|
|
|
|
|
.vscode/ |
|
.idea/ |
|
*.swp |
|
*.swo |
|
*~ |
|
|
|
|
|
.docker/ |
|
docker-data/ |
|
|
|
|
|
.ipynb_checkpoints/ |
|
*.ipynb |
|
|
|
|
|
htmlcov/ |
|
.coverage |
|
.coverage.* |
|
coverage.xml |
|
*.cover |
|
.hypothesis/ |
|
.pytest_cache/ |
|
EOF |
|
print_success "Archivo .gitignore creado" |
|
fi |
|
|
|
|
|
git add . |
|
|
|
|
|
if ! git log --oneline -1 &> /dev/null; then |
|
git commit -m "🚀 Initial commit: GPT Local project setup |
|
|
|
- ✅ Complete project structure with models, UI, and config |
|
- ✅ Docker support with multi-service configuration |
|
- ✅ Hugging Face and GitHub integration |
|
- ✅ Python CLI tools and utilities |
|
- ✅ Multiple model support (DialoGPT, Mistral, Gemma) |
|
- ✅ Terminal and web chat interfaces |
|
- ✅ Apple Silicon MPS optimization |
|
- ✅ Comprehensive documentation and setup scripts" |
|
print_success "Commit inicial creado" |
|
fi |
|
} |
|
|
|
|
|
push_to_github() { |
|
print_status "Subiendo código a GitHub..." |
|
|
|
|
|
if ! git remote | grep -q "origin"; then |
|
print_error "No hay remoto configurado. Ejecuta create_github_repo primero" |
|
return 1 |
|
fi |
|
|
|
|
|
if git push -u origin main 2>/dev/null || git push -u origin master 2>/dev/null; then |
|
print_success "Código subido a GitHub exitosamente" |
|
|
|
|
|
local repo_url=$(git remote get-url origin | sed 's/\.git$//') |
|
print_status "Repositorio disponible en: $repo_url" |
|
else |
|
print_error "Error subiendo a GitHub" |
|
return 1 |
|
fi |
|
} |
|
|
|
|
|
create_huggingface_readme() { |
|
cat > README_HF.md << 'EOF' |
|
--- |
|
title: GPT Local Chat |
|
emoji: 🤖 |
|
colorFrom: blue |
|
colorTo: green |
|
sdk: gradio |
|
sdk_version: 4.44.1 |
|
app_file: main.py |
|
pinned: false |
|
license: mit |
|
tags: |
|
- chatbot |
|
- gpt |
|
- huggingface |
|
- pytorch |
|
- transformers |
|
- gradio |
|
- spanish |
|
- conversational-ai |
|
--- |
|
|
|
|
|
|
|
Un sistema de chat GPT local potenciado por modelos de Hugging Face. |
|
|
|
|
|
|
|
- 💬 Chat conversacional en tiempo real |
|
- 🤗 Múltiples modelos de Hugging Face |
|
- 🍎 Optimizado para Apple Silicon (MPS) |
|
- ⚡ GPU acceleration automática |
|
- 🌐 Interfaz web moderna con Gradio |
|
|
|
|
|
|
|
- DialoGPT (small/medium/large) |
|
- Mistral 7B Instruct |
|
- Google Gemma 2B |
|
|
|
|
|
|
|
Simplemente escribe tu mensaje y presiona Enter para chatear con el modelo. |
|
|
|
|
|
|
|
El código completo está disponible en: [GitHub Repository](https://github.com/tu-usuario/gpt-local) |
|
EOF |
|
print_success "README de Hugging Face creado" |
|
} |
|
|
|
|
|
main() { |
|
local action=${1:-"full"} |
|
local repo_name=${2:-"gpt-local"} |
|
|
|
print_status "🚀 Iniciando gestión de repositorios..." |
|
|
|
case $action in |
|
"github") |
|
setup_git |
|
create_github_repo "$repo_name" |
|
push_to_github |
|
;; |
|
"huggingface") |
|
create_huggingface_readme |
|
create_huggingface_repo "$repo_name" "space" |
|
;; |
|
"full") |
|
setup_git |
|
create_github_repo "$repo_name" |
|
push_to_github |
|
create_huggingface_readme |
|
create_huggingface_repo "$repo_name" "space" |
|
;; |
|
"setup") |
|
setup_git |
|
;; |
|
"push") |
|
push_to_github |
|
;; |
|
*) |
|
echo "Uso: $0 [github|huggingface|full|setup|push] [nombre_repo]" |
|
echo "" |
|
echo "Comandos:" |
|
echo " github - Crear solo repositorio GitHub" |
|
echo " huggingface - Crear solo Hugging Face Space" |
|
echo " full - Crear ambos repositorios" |
|
echo " setup - Solo configurar Git local" |
|
echo " push - Solo subir cambios a GitHub" |
|
exit 1 |
|
;; |
|
esac |
|
|
|
print_success "✅ Gestión de repositorios completada!" |
|
} |
|
|
|
|
|
main "$@" |
|
|