textilindo-ai-assistant / fix_build_hf.sh
harismlnaslm's picture
Fix build issues - remove problematic dependencies and add data integration
8cc5253
#!/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"