🧠 RAG Core
Sistema modular de RAG (Retrieval Augmented Generation) desenvolvido para ser reutilizável e escalável, com suporte a múltiplos tenants e diferentes provedores de LLM.
🌟 Características
- ✨ Arquitetura Event-Driven: Baseada em Kafka para processamento assíncrono
- 🔄 Pipeline Modular: Extração → Embedding → Armazenamento → Recuperação → Geração
- 🔌 Múltiplos Provedores: Suporte a diferentes LLMs (Gemini, OpenAI, Mistral, etc.)
- 📊 Vector Store: Integração com Qdrant para busca semântica
- 📦 MongoDB: Armazenamento de documentos e metadados
- 🔐 Multi-tenant: Isolamento completo entre diferentes clientes
- 📈 Observabilidade: OpenTelemetry para traces, métricas e logs
🚀 Começando
Pré-requisitos
- Python 3.10+
- Docker e Docker Compose
- Make (opcional, mas recomendado)
Instalação
- Clone o repositório:
git clone https://github.com/seu-usuario/rag_core.git
cd rag_core
- Crie e ative um ambiente virtual:
python -m venv .venv
source .venv/bin/activate # Linux/Mac
# ou
.venv\Scripts\activate # Windows
- Instale as dependências:
pip install -r requirements.txt
- Copie o arquivo de exemplo de variáveis de ambiente:
cp .env.example .env
- Inicie os serviços com Docker Compose:
docker-compose up -d
🔧 Configuração
Edite o arquivo .env com suas configurações:
# Kafka
KAFKA_BOOTSTRAP_SERVERS=localhost:9092
# Qdrant
QDRANT_HOST=localhost
QDRANT_PORT=6333
# MongoDB
MONGODB_URI=mongodb://localhost:27017
# LLM Providers
GEMINI_API_KEY=sua_chave_aqui
OPENAI_API_KEY=sua_chave_aqui
📚 Como Usar
Uso Básico
from rag_core.core_orchestrator import CoreOrchestrator
from rag_core.events.event_bus import EventBus
from rag_core.events.event_types import DOCUMENT_UPLOADED, QUESTION_RECEIVED
# Inicializa o core
core = CoreOrchestrator()
core.start()
# Obtém instância do EventBus
event_bus = EventBus()
# Envia um documento
event_bus.emit(DOCUMENT_UPLOADED, {
"tenant_id": "empresa_x",
"session_id": "sessao_123",
"file_path": "/caminho/para/documento.pdf",
"file_type": "pdf"
})
# Faz uma pergunta
event_bus.emit(QUESTION_RECEIVED, {
"tenant_id": "empresa_x",
"session_id": "sessao_123",
"question": "Qual é o procedimento para...?",
"metadata": {
"language": "pt-BR",
"max_tokens": 500
}
})
Usando como Dependência
Instale o pacote via pip:
pip install rag_core
Ou adicione ao seu requirements.txt:
rag_core @ git+https://github.com/seu-usuario/rag_core.git
🏗️ Arquitetura
O sistema é dividido em camadas:
- Extraction Layer: Extrai texto de diferentes tipos de documento
- Embedding Layer: Gera embeddings usando diferentes provedores
- Vector Store Layer: Armazena e recupera vetores
- Retrieval Layer: Realiza busca semântica
- Generation Layer: Gera respostas usando LLMs
🔄 Eventos
O sistema usa os seguintes eventos principais:
DOCUMENT_UPLOADED: Documento enviado para processamentoDOCUMENT_EXTRACTED: Texto extraído do documentoEMBEDDING_CREATED: Embedding geradoVECTOR_STORED: Vetor armazenado no QdrantQUESTION_RECEIVED: Pergunta recebidaDOCUMENTS_RETRIEVED: Documentos relevantes recuperadosANSWER_GENERATED: Resposta final gerada
🧪 Testes
Execute os testes com:
pytest
📝 Licença
Este projeto está sob a licença MIT. Veja o arquivo LICENSE para mais detalhes.
🤝 Contribuindo
- Faça o fork do projeto
- Crie sua feature branch (
git checkout -b feature/AmazingFeature) - Commit suas mudanças (
git commit -m 'Add some AmazingFeature') - Push para a branch (
git push origin feature/AmazingFeature) - Abra um Pull Request
📞 Suporte
Para suporte, abra uma issue no GitHub ou entre em contato via [email].
Metadata
Release files for veolia-rag-core 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| veolia_rag_core-0.1.1.tar.gz | 28.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| veolia_rag_core-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.7 kB
Release files / veolia_rag_core-0.1.1.tar.gz
| Download URL | veolia_rag_core-0.1.1.tar.gz |
|---|---|
| Size | 28.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
37cbe97296566c71a2ce9079bc84a219426ff73932bce26c48364c677d5c7b6a
|
|
BLAKE2b-256 checksum How to use checksums |
c8f735f0fe35b5faaf6e229e93211abad2c68f9e8b073576a45f7f4e5990a04d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / veolia_rag_core-0.1.1-py3-none-any.whl
| Download URL | veolia_rag_core-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
89967e6226684ab42aacd2912e478146f31392fc992df4a42521c7306d5a3d3f
|
|
BLAKE2b-256 checksum How to use checksums |
412b64f4b54cf70d3b6b12931016bbb8d8868959cd6cf0e764f24a80da90b6fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for veolia-rag-core 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.