#!/bin/bash echo "🔧 Fixing HF Space build issues..." # Copy fixed requirements if [ -f "requirements_fixed.txt" ]; then cp requirements_fixed.txt requirements.txt echo "✅ Updated requirements.txt" else echo "❌ requirements_fixed.txt not found" exit 1 fi # Copy app with data integration if [ -f "app_with_data.py" ]; then cp app_with_data.py app.py echo "✅ Updated app.py" else echo "❌ app_with_data.py not found" exit 1 fi # Create Dockerfile for HF Spaces cat > Dockerfile << 'EOF' FROM python:3.9 # Create user RUN useradd -m -u 1000 user # Set working directory WORKDIR /app # Copy requirements first for better caching COPY --chown=user ./requirements.txt requirements.txt # Install dependencies RUN pip install --no-cache-dir --upgrade -r requirements.txt # Create necessary directories RUN mkdir -p /app/data /app/templates /app/configs # Copy application files COPY --chown=user . /app # Switch to user USER user # Expose port EXPOSE 8080 # Run the application CMD ["python", "app.py"] EOF echo "✅ Created Dockerfile" # Create README.md for HF Spaces cat > README.md << 'EOF' --- title: Textilindo AI Assistant emoji: 🤖 colorFrom: blue colorTo: purple sdk: docker pinned: false license: mit app_port: 8080 --- # Textilindo AI Assistant AI-powered customer service assistant for Textilindo textile company. ## Features - 🤖 **Smart AI Assistant**: Answers customer questions about products, shipping, and company policies - 📚 **Knowledge Base**: Uses 182+ training examples for context-aware responses - 🇮🇩 **Indonesian Language**: Responds in friendly Indonesian language - 🛍️ **Sales Focus**: Helps customers with product recommendations and ordering ## API Endpoints - `GET /` - API documentation - `GET /health` - Health check - `POST /chat` - Chat with AI - `GET /stats` - Dataset statistics ## Usage Send a POST request to `/chat` with your message: ```json { "message": "dimana lokasi textilindo?", "max_tokens": 300, "temperature": 0.7 } ``` ## Dataset The assistant is trained on 182+ examples covering: - Company location and hours - Product information - Shipping and payment policies - Customer service scenarios ## Technology - **Backend**: Flask (Python) - **AI**: Hugging Face Transformers - **Data**: JSONL format with RAG (Retrieval-Augmented Generation) - **Deployment**: Hugging Face Spaces EOF echo "✅ Created README.md" # Add and commit changes echo "📝 Committing changes..." git add . git commit -m "Fix build issues - remove problematic dependencies and add data integration - Remove difflib2 dependency (doesn't exist) - Use built-in difflib module instead - Add comprehensive dataset integration - Create proper Dockerfile for HF Spaces - Add README with documentation" # Push to Hugging Face Space echo "🚀 Pushing to Hugging Face Space..." git push hf main echo "✅ Build fix complete!" echo "" echo "📋 Next steps:" echo "1. Check your HF Space build status: https://huggingface.co/spaces/harismlnaslm/Textilindo" echo "2. Monitor the build logs" echo "3. Test your application once build completes"