Spaces:
Running
Running
File size: 4,163 Bytes
93b02ac 498cca6 93b02ac 498cca6 93b02ac 498cca6 93b02ac 498cca6 93b02ac 498cca6 93b02ac 498cca6 93b02ac 498cca6 93b02ac 498cca6 |
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 |
#!/bin/bash
set -e # Exit on any error
echo "π§ Setting up Saem's Tunes AI development environment"
echo "===================================================="
# Check Python version
echo "π Checking Python version..."
python --version || { echo "β Python not found"; exit 1; }
# Create virtual environment
echo "π¦ Creating Python virtual environment..."
python -m venv venv
source venv/bin/activate
# Upgrade pip
echo "π₯ Upgrading pip..."
pip install --upgrade pip
# Install dependencies
echo "π₯ Installing dependencies..."
pip install -r requirements.txt
pip install -r requirements-dev.txt
echo "β
Dependencies installed"
# Create necessary directories
echo "π Creating directory structure..."
mkdir -p models logs config tests/monitoring static
# Setup pre-commit hooks
echo "π¨ Setting up pre-commit hooks..."
pre-commit install || echo "β οΈ pre-commit not available, skipping"
# Create environment template if it doesn't exist
if [ ! -f .env ]; then
echo "π Creating environment file..."
cp .env.example .env
echo "β οΈ Please update .env with your actual values"
fi
# Create test configuration
echo "π§ͺ Creating test configuration..."
cat > tests/test_config.py << 'EOF'
"""Test configuration for Saem's Tunes AI"""
TEST_CONFIG = {
"supabase": {
"url": "https://test.supabase.co",
"key": "test_key"
},
"model": {
"name": "microsoft/Phi-3.5-mini-instruct",
"quantization": "Q4_K_M"
},
"security": {
"rate_limit": 60,
"max_input_length": 10000
}
}
EOF
# Create development startup script
echo "π Creating development startup script..."
cat > run_dev.sh << 'EOF'
#!/bin/bash
source venv/bin/activate
export LOG_LEVEL=DEBUG
export ENVIRONMENT=development
python app.py
EOF
chmod +x run_dev.sh
# Create production startup script
echo "π Creating production startup script..."
cat > run_prod.sh << 'EOF'
#!/bin/bash
source venv/bin/activate
export LOG_LEVEL=INFO
export ENVIRONMENT=production
python railway_app.py
EOF
chmod +x run_prod.sh
# Download model script
echo "π₯ Creating model download script..."
cat > download_model.py << 'EOF'
#!/usr/bin/env python3
import os
from huggingface_hub import hf_hub_download
import argparse
def main():
parser = argparse.ArgumentParser(description="Download Phi-3.5-mini-instruct model")
parser.add_argument("--repo", default="Thetima4/Phi-3.5-mini-instruct-Q4_K_M-GGUF",
help="Hugging Face repository ID")
parser.add_argument("--file", default="Phi-3.5-mini-instruct-q4_k_m.gguf",
help="Model filename")
parser.add_argument("--dir", default="./models",
help="Local directory to save the model")
args = parser.parse_args()
print(f"π₯ Downloading model from {args.repo}")
print(f"π Model file: {args.file}")
print(f"πΎ Local directory: {args.dir}")
# Create local directory if it doesn't exist
os.makedirs(args.dir, exist_ok=True)
try:
# Download the model
model_path = hf_hub_download(
repo_id=args.repo,
filename=args.file,
local_dir=args.dir,
local_dir_use_symlinks=False
)
print(f"β
Model downloaded successfully: {model_path}")
return model_path
except Exception as e:
print(f"β Error downloading model: {e}")
return None
if __name__ == "__main__":
main()
EOF
chmod +x download_model.py
echo "β
Environment setup completed!"
echo ""
echo "π Next steps:"
echo "1. Update .env with your actual environment variables"
echo "2. Run: source venv/bin/activate"
echo "3. Download model: python download_model.py"
echo "4. Test the system: python app.py"
echo "5. Run tests: pytest tests/"
echo ""
echo "π― Development commands:"
echo " ./run_dev.sh # Start development server"
echo " ./run_prod.sh # Start production server"
echo " pytest tests/ # Run test suite"
echo " black src/ # Format code"
echo " flake8 src/ # Lint code"
echo ""
echo "π Happy coding!" |