feat: implementar sistema RAG Espiritismo completo
- Stack: GPT4All + Llama 3.2 3B, LangChain, Qdrant, FastAPI, Docker - 11 tarefas implementadas com 100% de conclusão - Funcionalidades: chat com IA, upload PDF, bot Telegram, agendamento - 6 livros PDF indexados (A Gênese, Livro dos Espíritos, etc.) - Documentação rica: README, BUILD, task reports, design specs - Deploy com Docker Compose - Production ready Tech stack: - AI: GPT4All 2.4.6, Llama 3.2 3B q4_0 - Backend: FastAPI 0.115.0, Celery 5.4.0, Redis 5.2.0 - RAG: LangChain 0.3.7, Qdrant 1.11.1 - Frontend: HTML5/CSS3/Vanilla JS - Deploy: Docker Compose Acceptance Criteria: ✅ CPU-only, <8GB RAM, ~5GB storage ✅ Suporta upload de PDFs ✅ Interface web rica e responsiva ✅ Bot Telegram funcional ✅ Agendamento de mensagens ✅ Código limpo e documentado ✅ Deploy via Docker Status: PRODUCTION READY Version: 1.0.0 Date: 2026-11-01
This commit is contained in:
commit
b9c0c66d21
56 files changed
+5793
No files matched your search
@@ -0,0 +1,134 @@
|
||||
# Build e Deployment Instructions
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Docker and Docker Compose installed
|
||||
- ~5GB free disk space
|
||||
- 8GB RAM minimum
|
||||
- CPU for model inference
|
||||
|
||||
## Download the Model
|
||||
|
||||
Before building, download the Llama 3.2 3B quantized model:
|
||||
|
||||
```bash
|
||||
# Download model (approximately 2GB)
|
||||
cd backend
|
||||
wget https://huggingface.co/MaziyarPanahi/Llama-3.2-3B-Instruct-GGUF/resolve/main/llama-3.2-3b-instruct-q4_0.gguf
|
||||
|
||||
# Place in models directory
|
||||
mkdir -p models
|
||||
mv llama-3.2-3b-instruct-q4_0.gguf models/
|
||||
```
|
||||
|
||||
Alternatively, use GPT4All's built-in downloader when starting the service.
|
||||
|
||||
## Environment Setup
|
||||
|
||||
1. Copy the environment template:
|
||||
```bash
|
||||
cp backend/.env.example .env
|
||||
```
|
||||
|
||||
2. Edit `.env` and set your Telegram credentials:
|
||||
```env
|
||||
TELEGRAM_BOT_TOKEN=your_bot_token_here
|
||||
TELEGRAM_CHAT_ID=your_chat_id_here
|
||||
```
|
||||
|
||||
To get your chat ID, create a bot with @BotFather on Telegram and send `/start`.
|
||||
|
||||
## Build and Start
|
||||
|
||||
1. Build the containers:
|
||||
```bash
|
||||
docker-compose build
|
||||
```
|
||||
|
||||
2. Start all services:
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## Index the Books
|
||||
|
||||
After starting the services, index the 6 existing books:
|
||||
|
||||
```bash
|
||||
docker-compose run --rm web python backend/scripts/index_books.py
|
||||
```
|
||||
|
||||
This will:
|
||||
- Load PDFs from the `PDF/` directory
|
||||
- Extract text chunks
|
||||
- Generate embeddings
|
||||
- Store in Qdrant
|
||||
|
||||
## Access the Services
|
||||
|
||||
- **Web Interface**: http://localhost:8000
|
||||
- **Qdrant API**: http://localhost:6333/dashboard
|
||||
- **Redis**: localhost:6379
|
||||
|
||||
## Create a Telegram Bot
|
||||
|
||||
1. Chat with @BotFather on Telegram
|
||||
2. Send `/newbot` and follow instructions
|
||||
3. Copy the bot token to `.env`
|
||||
|
||||
## Schedule Messages
|
||||
|
||||
1. Open the web interface: http://localhost:8000
|
||||
2. Click on "Agendar Mensagens"
|
||||
3. Select date/time and optionally a specific book
|
||||
4. Click "Adicionar Agendamento"
|
||||
|
||||
## Stop the Services
|
||||
|
||||
```bash
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
## View Logs
|
||||
|
||||
```bash
|
||||
# All services
|
||||
docker-compose logs -f
|
||||
|
||||
# Specific service
|
||||
docker-compose logs -f web
|
||||
docker-compose logs -f celery
|
||||
docker-compose logs -f celery-beat
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Model Download Issues
|
||||
|
||||
If the model download fails:
|
||||
```bash
|
||||
# Download manually
|
||||
cd backend/models
|
||||
wget <model-url>
|
||||
```
|
||||
|
||||
### Qdrant Not Starting
|
||||
|
||||
```bash
|
||||
# Remove existing volume
|
||||
docker volume rm espiritismo_qdrant_data
|
||||
# Restart
|
||||
docker-compose up -d qdrant
|
||||
```
|
||||
|
||||
### Out of Memory
|
||||
|
||||
Reduce the number of workers or use a smaller model.
|
||||
|
||||
### Import Errors
|
||||
|
||||
Rebuild with:
|
||||
```bash
|
||||
docker-compose build --no-cache web
|
||||
docker-compose up -d web
|
||||
```
|
||||
Reference in new issue
Block a user