File size: 4,358 Bytes
298d6c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/usr/bin/env python3
"""
Deployment script for Hugging Face Spaces
"""

import os
import sys
import subprocess
from pathlib import Path

def check_requirements():
    """Check if required tools are available"""
    print("πŸ” Checking requirements...")
    
    # Check if git is available
    try:
        subprocess.run(["git", "--version"], capture_output=True, check=True)
        print("βœ… Git available")
    except (subprocess.CalledProcessError, FileNotFoundError):
        print("❌ Git not found. Please install git.")
        return False
    
    # Check if huggingface_hub is available
    try:
        import huggingface_hub
        print("βœ… Hugging Face Hub available")
    except ImportError:
        print("❌ Hugging Face Hub not found. Install with: pip install huggingface_hub")
        return False
    
    return True

def setup_git_lfs():
    """Setup Git LFS for large files"""
    print("πŸ“ Setting up Git LFS...")
    try:
        subprocess.run(["git", "lfs", "install"], check=True)
        print("βœ… Git LFS installed")
        return True
    except subprocess.CalledProcessError:
        print("❌ Failed to install Git LFS")
        return False

def create_gitignore():
    """Create .gitignore for the project"""
    print("πŸ“ Creating .gitignore...")
    
    gitignore_content = """
# Python
__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

# Virtual environments
venv/
env/
ENV/

# IDE
.vscode/
.idea/
*.swp
*.swo

# OS
.DS_Store
Thumbs.db

# Model files (too large for git)
models/
*.bin
*.safetensors
*.pt
*.pth

# Cache
.cache/
__pycache__/

# Logs
*.log
logs/

# Temporary files
*.tmp
*.temp

# Environment variables
.env
.env.local
.env.production

# Hugging Face
.huggingface/
transformers_cache/
"""
    
    with open(".gitignore", "w") as f:
        f.write(gitignore_content.strip())
    
    print("βœ… .gitignore created")

def create_readme():
    """Create README.md for the Space"""
    print("πŸ“– Creating README.md...")
    
    readme_content = """---
title: Textilindo AI Assistant
emoji: πŸ€–
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
license: mit
app_port: 7860
---

# Textilindo AI Assistant

AI Assistant for Textilindo with training and inference capabilities.

## Features

- πŸ€– AI model training with LoRA
- πŸ“Š Dataset creation and management
- πŸ§ͺ Model testing and inference
- πŸ”— External service integration
- πŸ“± Web interface for all operations

## Usage

1. **Check Training Ready**: Verify all components are ready
2. **Create Dataset**: Generate sample training data
3. **Setup Training**: Download models and setup environment
4. **Train Model**: Start the training process
5. **Test Model**: Interact with the trained model

## Hardware Requirements

- **Minimum**: CPU Basic (2 vCPU, 8GB RAM)
- **Recommended**: GPU Basic (1 T4 GPU, 16GB RAM)
- **For Training**: GPU A10G or higher

## Environment Variables

Set these in your Space settings:

- `HUGGINGFACE_TOKEN`: Your Hugging Face token (optional)
- `NOVITA_API_KEY`: Your Novita AI API key (optional)

## Support

For issues and questions, check the logs and health endpoint.
"""
    
    with open("README.md", "w") as f:
        f.write(readme_content)
    
    print("βœ… README.md created")

def main():
    """Main deployment function"""
    print("πŸš€ Textilindo AI Assistant - Hugging Face Spaces Deployment")
    print("=" * 60)
    
    # Check requirements
    if not check_requirements():
        print("❌ Requirements not met. Please install missing tools.")
        sys.exit(1)
    
    # Setup Git LFS
    if not setup_git_lfs():
        print("❌ Failed to setup Git LFS")
        sys.exit(1)
    
    # Create necessary files
    create_gitignore()
    create_readme()
    
    print("\nβœ… Deployment preparation complete!")
    print("\nπŸ“‹ Next steps:")
    print("1. Create a new Hugging Face Space")
    print("2. Use Docker SDK")
    print("3. Set hardware to GPU Basic or higher")
    print("4. Push your code to the Space repository")
    print("5. Set environment variables if needed")
    print("\nπŸ”— Your Space will be available at: https://huggingface.co/spaces/your-username/your-space-name")

if __name__ == "__main__":
    main()