verity-rag 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- verity_rag-0.1.0/.claude/settings.local.json +40 -0
- verity_rag-0.1.0/.dockerignore +68 -0
- verity_rag-0.1.0/.env.dev +52 -0
- verity_rag-0.1.0/.env.example +41 -0
- verity_rag-0.1.0/.gitignore +60 -0
- verity_rag-0.1.0/Dockerfile +33 -0
- verity_rag-0.1.0/Makefile +219 -0
- verity_rag-0.1.0/PKG-INFO +284 -0
- verity_rag-0.1.0/README.md +239 -0
- verity_rag-0.1.0/alembic.ini +36 -0
- verity_rag-0.1.0/docker-compose.yml +182 -0
- verity_rag-0.1.0/frontend/css/style.css +782 -0
- verity_rag-0.1.0/frontend/index.html +80 -0
- verity_rag-0.1.0/frontend/js/api.js +123 -0
- verity_rag-0.1.0/frontend/js/app.js +867 -0
- verity_rag-0.1.0/manual_test_upload.py +68 -0
- verity_rag-0.1.0/plans/quirky-pondering-wilkes.md +291 -0
- verity_rag-0.1.0/pyproject.toml +61 -0
- verity_rag-0.1.0/rag_agent/__init__.py +3 -0
- verity_rag-0.1.0/rag_agent/app.py +108 -0
- verity_rag-0.1.0/rag_agent/chunkers/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/chunkers/base.py +26 -0
- verity_rag-0.1.0/rag_agent/chunkers/markdown.py +38 -0
- verity_rag-0.1.0/rag_agent/chunkers/recursive.py +36 -0
- verity_rag-0.1.0/rag_agent/connectors/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/connectors/base.py +106 -0
- verity_rag-0.1.0/rag_agent/core/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/core/config.py +148 -0
- verity_rag-0.1.0/rag_agent/core/database.py +83 -0
- verity_rag-0.1.0/rag_agent/core/deps.py +35 -0
- verity_rag-0.1.0/rag_agent/core/exceptions.py +59 -0
- verity_rag-0.1.0/rag_agent/core/logging.py +65 -0
- verity_rag-0.1.0/rag_agent/core/retry.py +63 -0
- verity_rag-0.1.0/rag_agent/core/valkey.py +50 -0
- verity_rag-0.1.0/rag_agent/db/__init__.py +6 -0
- verity_rag-0.1.0/rag_agent/db/base.py +9 -0
- verity_rag-0.1.0/rag_agent/db/migrations/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/db/migrations/env.py +72 -0
- verity_rag-0.1.0/rag_agent/db/models/__init__.py +6 -0
- verity_rag-0.1.0/rag_agent/db/models/document.py +62 -0
- verity_rag-0.1.0/rag_agent/db/models/sync_log.py +46 -0
- verity_rag-0.1.0/rag_agent/embeddings/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/embeddings/base.py +39 -0
- verity_rag-0.1.0/rag_agent/embeddings/openai_compat.py +50 -0
- verity_rag-0.1.0/rag_agent/embeddings/service.py +108 -0
- verity_rag-0.1.0/rag_agent/models/__init__.py +31 -0
- verity_rag-0.1.0/rag_agent/models/collection.py +20 -0
- verity_rag-0.1.0/rag_agent/models/common.py +25 -0
- verity_rag-0.1.0/rag_agent/models/document.py +84 -0
- verity_rag-0.1.0/rag_agent/models/ingestion.py +42 -0
- verity_rag-0.1.0/rag_agent/models/search.py +39 -0
- verity_rag-0.1.0/rag_agent/parsers/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/parsers/base.py +42 -0
- verity_rag-0.1.0/rag_agent/parsers/docx.py +34 -0
- verity_rag-0.1.0/rag_agent/parsers/pdf.py +201 -0
- verity_rag-0.1.0/rag_agent/parsers/registry.py +50 -0
- verity_rag-0.1.0/rag_agent/parsers/text.py +31 -0
- verity_rag-0.1.0/rag_agent/pipeline/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/pipeline/file_storage.py +57 -0
- verity_rag-0.1.0/rag_agent/pipeline/image_describer.py +84 -0
- verity_rag-0.1.0/rag_agent/pipeline/ingestion.py +250 -0
- verity_rag-0.1.0/rag_agent/pipeline/processor.py +131 -0
- verity_rag-0.1.0/rag_agent/repositories/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/repositories/document_repo.py +151 -0
- verity_rag-0.1.0/rag_agent/repositories/sync_log_repo.py +70 -0
- verity_rag-0.1.0/rag_agent/rerankers/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/rerankers/base.py +55 -0
- verity_rag-0.1.0/rag_agent/rerankers/service.py +18 -0
- verity_rag-0.1.0/rag_agent/retrieval/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/retrieval/bm25.py +29 -0
- verity_rag-0.1.0/rag_agent/retrieval/service.py +144 -0
- verity_rag-0.1.0/rag_agent/routes/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/routes/collections.py +98 -0
- verity_rag-0.1.0/rag_agent/routes/documents.py +146 -0
- verity_rag-0.1.0/rag_agent/routes/health.py +83 -0
- verity_rag-0.1.0/rag_agent/routes/search.py +146 -0
- verity_rag-0.1.0/rag_agent/routes/sync.py +113 -0
- verity_rag-0.1.0/rag_agent/schemas/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/schemas/collection.py +21 -0
- verity_rag-0.1.0/rag_agent/schemas/common.py +38 -0
- verity_rag-0.1.0/rag_agent/schemas/document.py +74 -0
- verity_rag-0.1.0/rag_agent/schemas/search.py +48 -0
- verity_rag-0.1.0/rag_agent/services/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/services/document_service.py +181 -0
- verity_rag-0.1.0/rag_agent/services/status_service.py +57 -0
- verity_rag-0.1.0/rag_agent/services/sync_service.py +105 -0
- verity_rag-0.1.0/rag_agent/vectorstore/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/vectorstore/base.py +134 -0
- verity_rag-0.1.0/rag_agent/vectorstore/milvus.py +181 -0
- verity_rag-0.1.0/rag_agent/vectorstore/service.py +66 -0
- verity_rag-0.1.0/rag_agent/worker/__init__.py +0 -0
- verity_rag-0.1.0/rag_agent/worker/dispatcher.py +35 -0
- verity_rag-0.1.0/rag_agent/worker/settings.py +155 -0
- verity_rag-0.1.0/run_server.sh +1 -0
- verity_rag-0.1.0/scripts/create_tables.py +33 -0
- verity_rag-0.1.0/scripts/run_migrations.py +42 -0
- verity_rag-0.1.0/scripts/wait_for_services.py +163 -0
- verity_rag-0.1.0/test_smoke.py +26 -0
- verity_rag-0.1.0/test_upload_logic.py +67 -0
- verity_rag-0.1.0/test_with_curl.sh +21 -0
- verity_rag-0.1.0/tests/__init__.py +0 -0
- verity_rag-0.1.0/tests/api/__init__.py +0 -0
- verity_rag-0.1.0/tests/api/test_documents.py +140 -0
- verity_rag-0.1.0/tests/conftest.py +88 -0
- verity_rag-0.1.0/tests/integration/__init__.py +0 -0
- verity_rag-0.1.0/tests/unit/__init__.py +0 -0
- verity_rag-0.1.0/uv.lock +3090 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(python *)",
|
|
5
|
+
"Bash(uvicorn rag_agent.app:create_app --factory --host 0.0.0.0 --port 8100)",
|
|
6
|
+
"Bash(xargs ls -la)",
|
|
7
|
+
"Bash(uv run *)",
|
|
8
|
+
"Bash(docker compose up *)",
|
|
9
|
+
"Bash(podman compose *)",
|
|
10
|
+
"Bash(docker compose ps *)",
|
|
11
|
+
"Bash(podman rm *)",
|
|
12
|
+
"Bash(podman exec *)",
|
|
13
|
+
"Bash(podman inspect *)",
|
|
14
|
+
"Bash(podman run *)",
|
|
15
|
+
"Bash(python3 *)",
|
|
16
|
+
"Bash(wkhtmltopdf - /tmp/test_document.pdf)",
|
|
17
|
+
"Bash(curl -s -X POST 'http://localhost:8100/api/v1/documents/upload?collection_name=documents&replace=true' -H 'Content-Type: multipart/form-data' -F file=@/tmp/test_document.pdf)",
|
|
18
|
+
"Bash(curl *)",
|
|
19
|
+
"Bash(kill %1)",
|
|
20
|
+
"Bash(ip addr *)",
|
|
21
|
+
"Bash(awk '{print $2}')",
|
|
22
|
+
"Bash(ip route *)",
|
|
23
|
+
"Bash(awk '{print $3}')",
|
|
24
|
+
"Bash(xargs -I{} ip addr show {})",
|
|
25
|
+
"Bash(podman network *)",
|
|
26
|
+
"Bash(sudo iptables -I INPUT -s 10.88.0.0/16 -p tcp --dport 8012 -j ACCEPT)",
|
|
27
|
+
"Bash(podman-compose ps *)",
|
|
28
|
+
"Bash(docker-compose ps *)",
|
|
29
|
+
"Bash(podman ps *)",
|
|
30
|
+
"Bash(podman logs *)",
|
|
31
|
+
"Bash(podman info *)",
|
|
32
|
+
"Bash(podman version *)",
|
|
33
|
+
"Bash(podman-compose stop *)",
|
|
34
|
+
"Bash(podman-compose rm *)",
|
|
35
|
+
"Bash(podman-compose up *)",
|
|
36
|
+
"Bash(env)",
|
|
37
|
+
"Bash(wait)"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Environment
|
|
2
|
+
.env
|
|
3
|
+
.env.local
|
|
4
|
+
.env.*.local
|
|
5
|
+
|
|
6
|
+
# Python
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
*$py.class
|
|
10
|
+
*.so
|
|
11
|
+
.Python
|
|
12
|
+
*.egg-info/
|
|
13
|
+
dist/
|
|
14
|
+
build/
|
|
15
|
+
*.egg
|
|
16
|
+
.eggs/
|
|
17
|
+
pip-log.txt
|
|
18
|
+
pip-delete-this-directory.txt
|
|
19
|
+
|
|
20
|
+
# Virtual environments - CRITICAL for Docker build performance
|
|
21
|
+
venv/
|
|
22
|
+
.venv/
|
|
23
|
+
env/
|
|
24
|
+
*/env/
|
|
25
|
+
*/venv/
|
|
26
|
+
|
|
27
|
+
# IDE
|
|
28
|
+
.idea/
|
|
29
|
+
.vscode/
|
|
30
|
+
*.swp
|
|
31
|
+
*.swo
|
|
32
|
+
*~
|
|
33
|
+
.DS_Store
|
|
34
|
+
|
|
35
|
+
# Testing
|
|
36
|
+
.pytest_cache/
|
|
37
|
+
.coverage
|
|
38
|
+
htmlcov/
|
|
39
|
+
.coverage.*
|
|
40
|
+
*.log
|
|
41
|
+
|
|
42
|
+
# Jupyter
|
|
43
|
+
.ipynb_checkpoints/
|
|
44
|
+
|
|
45
|
+
# Git
|
|
46
|
+
.git/
|
|
47
|
+
.gitignore
|
|
48
|
+
|
|
49
|
+
# Docker
|
|
50
|
+
Dockerfile*
|
|
51
|
+
docker-compose*
|
|
52
|
+
.dockerignore
|
|
53
|
+
|
|
54
|
+
# Data
|
|
55
|
+
data/
|
|
56
|
+
uploads/
|
|
57
|
+
media/
|
|
58
|
+
*.db
|
|
59
|
+
*.sqlite3
|
|
60
|
+
milvus-data/
|
|
61
|
+
|
|
62
|
+
# Vector stores & models
|
|
63
|
+
*.bin
|
|
64
|
+
*.pkl
|
|
65
|
+
*.joblib
|
|
66
|
+
*.onnx
|
|
67
|
+
.huggingface/
|
|
68
|
+
cache/
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# โโ Dev-Fast: Local development without application containers โโโโ
|
|
2
|
+
# Data infra (Postgres, Valkey, Milvus) still runs in containers
|
|
3
|
+
# but the API server and worker run directly on the host with hot-reload.
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# make dev-up # start data infra containers
|
|
7
|
+
# make dev-fast # run API with hot-reload
|
|
8
|
+
# make dev-fast-worker # run worker directly
|
|
9
|
+
# make dev-down # stop data infra containers
|
|
10
|
+
|
|
11
|
+
# โโ Infrastructure (uses docker-compose host port mappings) โโโโโ
|
|
12
|
+
DATABASE_URL=postgresql+asyncpg://rag:rag@localhost:5433/rag
|
|
13
|
+
VALKEY_URL=redis://localhost:6380/0
|
|
14
|
+
MILVUS_URI=http://localhost:19530
|
|
15
|
+
MILVUS_TOKEN=
|
|
16
|
+
|
|
17
|
+
# โโ Embeddings โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
18
|
+
# Set EMBEDDING_BASE_URL to empty to use local sentence-transformers
|
|
19
|
+
# Or point to an OpenAI-compatible endpoint (Ollama, vLLM, TEI, etc.)
|
|
20
|
+
EMBEDDING_BASE_URL=http://localhost:8012/v1
|
|
21
|
+
EMBEDDING_API_KEY=
|
|
22
|
+
EMBEDDING_MODEL=huoxu/all-MiniLM-L6-v2-Q8_0-GGUF:Q8_0
|
|
23
|
+
EMBEDDING_DIM=384
|
|
24
|
+
|
|
25
|
+
# โโ LLM (for image description) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
26
|
+
LLM_BASE_URL=
|
|
27
|
+
LLM_API_KEY=
|
|
28
|
+
LLM_MODEL=
|
|
29
|
+
|
|
30
|
+
# โโ Storage โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
31
|
+
MEDIA_DIR=./.dev-media
|
|
32
|
+
MAX_UPLOAD_SIZE_MB=50
|
|
33
|
+
|
|
34
|
+
# โโ Pipeline โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
35
|
+
CHUNK_SIZE=512
|
|
36
|
+
CHUNK_OVERLAP=50
|
|
37
|
+
CHUNKING_STRATEGY=recursive
|
|
38
|
+
ENABLE_HYBRID_SEARCH=false
|
|
39
|
+
ENABLE_OCR=false
|
|
40
|
+
ENABLE_IMAGE_DESCRIPTION=false
|
|
41
|
+
|
|
42
|
+
# โโ Reranker โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
43
|
+
CROSS_ENCODER_MODEL=cross-encoder/ms-marco-MiniLM-L6-v2
|
|
44
|
+
HF_TOKEN=
|
|
45
|
+
|
|
46
|
+
# โโ Server โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
47
|
+
HOST=0.0.0.0
|
|
48
|
+
PORT=8100
|
|
49
|
+
DEBUG=true
|
|
50
|
+
CORS_ORIGINS='["*"]'
|
|
51
|
+
LOG_LEVEL=DEBUG
|
|
52
|
+
LOG_FORMAT=console
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# โโ Infrastructure โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
2
|
+
DATABASE_URL=postgresql+asyncpg://rag:rag@localhost:5433/rag
|
|
3
|
+
VALKEY_URL=redis://localhost:6380/0
|
|
4
|
+
MILVUS_URI=http://localhost:19530
|
|
5
|
+
MILVUS_TOKEN=
|
|
6
|
+
|
|
7
|
+
# โโ Embeddings โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
8
|
+
# OpenAI-compatible endpoint (works with Ollama, vLLM, TEI, OpenAI)
|
|
9
|
+
EMBEDDING_BASE_URL=
|
|
10
|
+
EMBEDDING_API_KEY=
|
|
11
|
+
EMBEDDING_MODEL=all-MiniLM-L6-v2
|
|
12
|
+
EMBEDDING_DIM=384
|
|
13
|
+
|
|
14
|
+
# โโ LLM (for image description) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
15
|
+
LLM_BASE_URL=
|
|
16
|
+
LLM_API_KEY=
|
|
17
|
+
LLM_MODEL=
|
|
18
|
+
|
|
19
|
+
# โโ Storage โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
20
|
+
MEDIA_DIR=/data/media
|
|
21
|
+
MAX_UPLOAD_SIZE_MB=50
|
|
22
|
+
|
|
23
|
+
# โโ Pipeline โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
24
|
+
CHUNK_SIZE=512
|
|
25
|
+
CHUNK_OVERLAP=50
|
|
26
|
+
CHUNKING_STRATEGY=recursive
|
|
27
|
+
ENABLE_HYBRID_SEARCH=false
|
|
28
|
+
ENABLE_OCR=false
|
|
29
|
+
ENABLE_IMAGE_DESCRIPTION=true
|
|
30
|
+
|
|
31
|
+
# โโ Reranker โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
32
|
+
CROSS_ENCODER_MODEL=cross-encoder/ms-marco-MiniLM-L6-v2
|
|
33
|
+
HF_TOKEN=
|
|
34
|
+
|
|
35
|
+
# โโ Server โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
36
|
+
HOST=0.0.0.0
|
|
37
|
+
PORT=8100
|
|
38
|
+
DEBUG=false
|
|
39
|
+
CORS_ORIGINS=["*"]
|
|
40
|
+
LOG_LEVEL=INFO
|
|
41
|
+
LOG_FORMAT=json
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Environment
|
|
2
|
+
.env
|
|
3
|
+
.env.local
|
|
4
|
+
.env.*.local
|
|
5
|
+
|
|
6
|
+
# Python
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
*$py.class
|
|
10
|
+
*.so
|
|
11
|
+
.Python
|
|
12
|
+
*.egg-info/
|
|
13
|
+
dist/
|
|
14
|
+
build/
|
|
15
|
+
*.egg
|
|
16
|
+
.eggs/
|
|
17
|
+
pip-log.txt
|
|
18
|
+
pip-delete-this-directory.txt
|
|
19
|
+
|
|
20
|
+
# Virtual environments
|
|
21
|
+
venv/
|
|
22
|
+
.venv/
|
|
23
|
+
env/
|
|
24
|
+
*/env/
|
|
25
|
+
*/venv/
|
|
26
|
+
|
|
27
|
+
# IDE
|
|
28
|
+
.idea/
|
|
29
|
+
.vscode/
|
|
30
|
+
*.swp
|
|
31
|
+
*.swo
|
|
32
|
+
*~
|
|
33
|
+
.DS_Store
|
|
34
|
+
|
|
35
|
+
# Project specific
|
|
36
|
+
data/
|
|
37
|
+
uploads/
|
|
38
|
+
chroma_db/
|
|
39
|
+
*.db
|
|
40
|
+
*.sqlite3
|
|
41
|
+
milvus-data/
|
|
42
|
+
.dev-media/
|
|
43
|
+
|
|
44
|
+
# Testing
|
|
45
|
+
.pytest_cache/
|
|
46
|
+
.coverage
|
|
47
|
+
htmlcov/
|
|
48
|
+
.coverage.*
|
|
49
|
+
*.log
|
|
50
|
+
|
|
51
|
+
# Jupyter
|
|
52
|
+
.ipynb_checkpoints/
|
|
53
|
+
|
|
54
|
+
# Vector stores & models
|
|
55
|
+
*.bin
|
|
56
|
+
*.pkl
|
|
57
|
+
*.joblib
|
|
58
|
+
*.onnx
|
|
59
|
+
.huggingface/
|
|
60
|
+
cache/
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# โโ RAG Agent โ API & Worker โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
2
|
+
FROM python:3.12-slim AS base
|
|
3
|
+
|
|
4
|
+
ENV PYTHONUNBUFFERED=1 \
|
|
5
|
+
PYTHONDONTWRITEBYTECODE=1 \
|
|
6
|
+
PIP_NO_CACHE_DIR=1
|
|
7
|
+
|
|
8
|
+
# System dependencies for PyMuPDF and other native libs
|
|
9
|
+
RUN apt-get update && \
|
|
10
|
+
apt-get install -y --no-install-recommends \
|
|
11
|
+
curl \
|
|
12
|
+
libgomp1 \
|
|
13
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
14
|
+
|
|
15
|
+
WORKDIR /app
|
|
16
|
+
|
|
17
|
+
# Copy application source, configuration, and frontend
|
|
18
|
+
COPY pyproject.toml .
|
|
19
|
+
COPY rag_agent/ rag_agent/
|
|
20
|
+
COPY frontend/ frontend/
|
|
21
|
+
COPY alembic.ini .
|
|
22
|
+
|
|
23
|
+
# Install Python dependencies (requires source for hatchling wheel build)
|
|
24
|
+
RUN pip install --upgrade pip && \
|
|
25
|
+
pip install .
|
|
26
|
+
|
|
27
|
+
# Create media directory
|
|
28
|
+
RUN mkdir -p /data/media
|
|
29
|
+
|
|
30
|
+
EXPOSE 8100
|
|
31
|
+
|
|
32
|
+
# Default: run the API server
|
|
33
|
+
CMD ["uvicorn", "rag_agent.app:create_app", "--host", "0.0.0.0", "--port", "8100", "--factory"]
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# โโ RAG Agent Makefile โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
2
|
+
# Common tasks for development and deployment
|
|
3
|
+
# Requires: Podman or Docker (with compose), uv (https://github.com/astral-sh/uv)
|
|
4
|
+
|
|
5
|
+
SHELL := /bin/bash
|
|
6
|
+
export PYTHONPATH := $(PWD)
|
|
7
|
+
|
|
8
|
+
# โโ Container Runtime โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
9
|
+
# Auto-detect: prefers podman, falls back to docker.
|
|
10
|
+
# Override with: make CONTAINER_RUNTIME=docker up
|
|
11
|
+
CONTAINER_RUNTIME ?= $(shell if command -v podman &>/dev/null; then echo podman; elif command -v docker &>/dev/null; then echo docker; else echo docker; fi)
|
|
12
|
+
COMPOSE := $(CONTAINER_RUNTIME) compose
|
|
13
|
+
|
|
14
|
+
# โโ Environment โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
15
|
+
ifeq ($(shell uname -s),Darwin)
|
|
16
|
+
USER_ID := 501
|
|
17
|
+
GROUP_ID := 20
|
|
18
|
+
else
|
|
19
|
+
USER_ID := $(shell id -u)
|
|
20
|
+
GROUP_ID := $(shell id -g)
|
|
21
|
+
endif
|
|
22
|
+
|
|
23
|
+
# โโ Help โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
24
|
+
help:
|
|
25
|
+
@echo "RAG Agent Development Tasks"
|
|
26
|
+
@echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
27
|
+
@echo "setup - Install Python dependencies with uv"
|
|
28
|
+
@echo "test - Run test suite"
|
|
29
|
+
@echo "lint - Run linters (ruff)"
|
|
30
|
+
@echo "format - Format code (ruff format)"
|
|
31
|
+
@echo "typecheck - Run type checking (mypy)"
|
|
32
|
+
@echo ""
|
|
33
|
+
@echo "โโ Container Stack โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
34
|
+
@echo "up - Start full container stack"
|
|
35
|
+
@echo "down - Stop container stack"
|
|
36
|
+
@echo "logs - Show service logs"
|
|
37
|
+
@echo "ps - Show running containers"
|
|
38
|
+
@echo ""
|
|
39
|
+
@echo "โโ Dev-Fast (no app containers) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
40
|
+
@echo "dev-up - Start ONLY data infra (Postgres, Valkey, Milvus)"
|
|
41
|
+
@echo "dev-down - Stop data infra containers"
|
|
42
|
+
@echo "dev-logs - Show data infra logs"
|
|
43
|
+
@echo "dev-fast - Run API directly with hot-reload + .env.dev"
|
|
44
|
+
@echo "dev-fast-worker - Run worker directly with .env.dev"
|
|
45
|
+
@echo "dev-migrate - Run Alembic migrations against local infra"
|
|
46
|
+
@echo "dev-create-tables - Create tables directly (no Alembic)"
|
|
47
|
+
@echo "dev-setup - Create media dir + run migrations"
|
|
48
|
+
@echo ""
|
|
49
|
+
@echo "โโ Local Commands โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
50
|
+
@echo "worker - Start ARQ worker (outside Docker)"
|
|
51
|
+
@echo "run - Start API server (outside Docker)"
|
|
52
|
+
@echo "migrate - Run Alembic migrations"
|
|
53
|
+
@echo "wait - Wait for services to be ready"
|
|
54
|
+
@echo "clean - Clean build artifacts and __pycache__"
|
|
55
|
+
@echo ""
|
|
56
|
+
@echo "โโ Shell Access โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
57
|
+
@echo "shell - Open shell in API container"
|
|
58
|
+
@echo "db-shell - Open PostgreSQL shell (container)"
|
|
59
|
+
@echo "valkey-cli - Open Valkey CLI (container)"
|
|
60
|
+
@echo "milvus-cli - Open Milvus CLI (container)"
|
|
61
|
+
@echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
62
|
+
@echo "Example: make dev-up && make dev-setup && make dev-fast"
|
|
63
|
+
|
|
64
|
+
# โโ Python Dependencies โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
65
|
+
setup:
|
|
66
|
+
@echo "๐ฆ Installing Python dependencies with uv..."
|
|
67
|
+
uv sync --all-extras
|
|
68
|
+
|
|
69
|
+
.PHONY: setup
|
|
70
|
+
|
|
71
|
+
# โโ Testing โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
72
|
+
test:
|
|
73
|
+
@echo "๐งช Running test suite..."
|
|
74
|
+
uv run pytest tests/ -v
|
|
75
|
+
|
|
76
|
+
.PHONY: test
|
|
77
|
+
|
|
78
|
+
# โโ Linting and Formatting โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
79
|
+
lint:
|
|
80
|
+
@echo "๐ Running linters..."
|
|
81
|
+
uv run ruff check .
|
|
82
|
+
|
|
83
|
+
format:
|
|
84
|
+
@echo "โ๏ธ Formatting code..."
|
|
85
|
+
uv run ruff format .
|
|
86
|
+
|
|
87
|
+
typecheck:
|
|
88
|
+
@echo "โ
Running type checking..."
|
|
89
|
+
uv run mypy rag_agent/
|
|
90
|
+
|
|
91
|
+
.PHONY: lint format typecheck
|
|
92
|
+
|
|
93
|
+
# โโ Container Stack โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
94
|
+
up:
|
|
95
|
+
@echo "๐ณ Starting container stack with $(CONTAINER_RUNTIME)..."
|
|
96
|
+
$(COMPOSE) up -d
|
|
97
|
+
|
|
98
|
+
down:
|
|
99
|
+
@echo "โน๏ธ Stopping container stack..."
|
|
100
|
+
$(COMPOSE) down
|
|
101
|
+
|
|
102
|
+
logs:
|
|
103
|
+
@echo "๐ Showing service logs..."
|
|
104
|
+
$(COMPOSE) logs -f --tail=100
|
|
105
|
+
|
|
106
|
+
ps:
|
|
107
|
+
@echo "๐ Showing running containers..."
|
|
108
|
+
$(COMPOSE) ps
|
|
109
|
+
|
|
110
|
+
.PHONY: up down logs ps
|
|
111
|
+
|
|
112
|
+
# โโ Development โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
113
|
+
run:
|
|
114
|
+
@echo "๐ Starting API server..."
|
|
115
|
+
uv run uvicorn rag_agent.app:create_app --reload --factory --host 0.0.0.0 --port 8100
|
|
116
|
+
|
|
117
|
+
worker:
|
|
118
|
+
@echo "โก Starting ARQ worker..."
|
|
119
|
+
uv run arq rag_agent.worker.settings.WorkerSettings
|
|
120
|
+
|
|
121
|
+
migrate:
|
|
122
|
+
@echo "๐ Running database migrations..."
|
|
123
|
+
uv run alembic revision --autogenerate -m "Auto-generated migration"
|
|
124
|
+
uv run alembic upgrade head
|
|
125
|
+
|
|
126
|
+
wait:
|
|
127
|
+
@echo "โณ Waiting for services to be ready..."
|
|
128
|
+
python scripts/wait_for_services.py
|
|
129
|
+
|
|
130
|
+
.PHONY: run worker migrate wait
|
|
131
|
+
|
|
132
|
+
# โโ Dev-Fast (data infra in containers, app on host) โโโโโโโโโโโโโ
|
|
133
|
+
DEV_COMPOSE_SERVICES := postgres valkey milvus-etcd milvus-minio milvus
|
|
134
|
+
|
|
135
|
+
dev-up:
|
|
136
|
+
@echo "๐ณ Starting data infrastructure (Postgres, Valkey, Milvus)..."
|
|
137
|
+
$(COMPOSE) up -d $(DEV_COMPOSE_SERVICES)
|
|
138
|
+
@echo ""
|
|
139
|
+
@echo "โณ Waiting for services to be ready..."
|
|
140
|
+
@$(MAKE) wait 2>/dev/null || echo "โ ๏ธ wait script may fail if API not running; check 'make dev-logs'"
|
|
141
|
+
@echo ""
|
|
142
|
+
@echo "๐ Next steps:"
|
|
143
|
+
@echo " make dev-setup # create media dir + run migrations"
|
|
144
|
+
@echo " make dev-fast # start API with hot-reload"
|
|
145
|
+
|
|
146
|
+
dev-down:
|
|
147
|
+
@echo "โน๏ธ Stopping data infrastructure..."
|
|
148
|
+
$(COMPOSE) down
|
|
149
|
+
|
|
150
|
+
dev-logs:
|
|
151
|
+
@echo "๐ Showing data infra logs..."
|
|
152
|
+
$(COMPOSE) logs -f --tail=100 $(DEV_COMPOSE_SERVICES)
|
|
153
|
+
|
|
154
|
+
# Helper: source .env.dev directly so variables are set in the current shell.
|
|
155
|
+
# This avoids glob-expansion issues with values like CORS_ORIGINS=["*"].
|
|
156
|
+
# (set -a ensures all sourced variables are exported to the environment)
|
|
157
|
+
DEV_ENV := set -a; . .env.dev; set +a;
|
|
158
|
+
|
|
159
|
+
dev-setup:
|
|
160
|
+
@echo "๐ Creating local media directory..."
|
|
161
|
+
@mkdir -p .dev-media
|
|
162
|
+
@echo "๐ Running database migrations..."
|
|
163
|
+
-$(DEV_ENV) uv run alembic upgrade head
|
|
164
|
+
@echo "โ
Dev environment ready!"
|
|
165
|
+
|
|
166
|
+
dev-migrate:
|
|
167
|
+
@echo "๐ Running database migrations..."
|
|
168
|
+
$(DEV_ENV) uv run alembic revision --autogenerate -m "Auto-generated migration"
|
|
169
|
+
$(DEV_ENV) uv run alembic upgrade head
|
|
170
|
+
|
|
171
|
+
dev-create-tables:
|
|
172
|
+
@echo "๐๏ธ Creating database tables directly..."
|
|
173
|
+
$(DEV_ENV) uv run python scripts/create_tables.py
|
|
174
|
+
|
|
175
|
+
dev-fast:
|
|
176
|
+
@echo "๐ Starting API server (hot-reload, no container)..."
|
|
177
|
+
$(DEV_ENV) uv run uvicorn rag_agent.app:create_app \
|
|
178
|
+
--reload \
|
|
179
|
+
--factory \
|
|
180
|
+
--host 0.0.0.0 \
|
|
181
|
+
--port 8100
|
|
182
|
+
|
|
183
|
+
dev-fast-worker:
|
|
184
|
+
@echo "โก Starting ARQ worker (no container)..."
|
|
185
|
+
$(DEV_ENV) uv run arq rag_agent.worker.settings.WorkerSettings
|
|
186
|
+
|
|
187
|
+
.PHONY: dev-up dev-down dev-logs dev-setup dev-migrate dev-create-tables dev-fast dev-fast-worker
|
|
188
|
+
|
|
189
|
+
# โโ Shell Access โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
190
|
+
shell:
|
|
191
|
+
@echo "๐ Opening shell in API container..."
|
|
192
|
+
$(COMPOSE) exec api bash
|
|
193
|
+
|
|
194
|
+
db-shell:
|
|
195
|
+
@echo "๐ Opening PostgreSQL shell..."
|
|
196
|
+
$(COMPOSE) exec postgres psql -U rag rag
|
|
197
|
+
|
|
198
|
+
valkey-cli:
|
|
199
|
+
@echo "โก Opening Valkey CLI..."
|
|
200
|
+
$(COMPOSE) exec valkey valkey-cli
|
|
201
|
+
|
|
202
|
+
milvus-cli:
|
|
203
|
+
@echo "๐ Opening Milvus CLI..."
|
|
204
|
+
$(COMPOSE) exec milvus milvus_cli
|
|
205
|
+
|
|
206
|
+
.PHONY: shell db-shell valkey-cli milvus-cli
|
|
207
|
+
|
|
208
|
+
# โโ Clean โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
209
|
+
clean:
|
|
210
|
+
@echo "๐งน Cleaning build artifacts..."
|
|
211
|
+
find . -type f -name "*.pyc" -delete
|
|
212
|
+
find . -type d -name "__pycache__" -exec rm -rf {} +
|
|
213
|
+
find . -type f -name "*.log" -delete
|
|
214
|
+
rm -rf .venv .pytest_cache .ruff_cache .mypy_cache
|
|
215
|
+
|
|
216
|
+
.PHONY: clean
|
|
217
|
+
|
|
218
|
+
# โโ Default Target โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
219
|
+
.DEFAULT_GOAL := help
|