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.
Files changed (107) hide show
  1. verity_rag-0.1.0/.claude/settings.local.json +40 -0
  2. verity_rag-0.1.0/.dockerignore +68 -0
  3. verity_rag-0.1.0/.env.dev +52 -0
  4. verity_rag-0.1.0/.env.example +41 -0
  5. verity_rag-0.1.0/.gitignore +60 -0
  6. verity_rag-0.1.0/Dockerfile +33 -0
  7. verity_rag-0.1.0/Makefile +219 -0
  8. verity_rag-0.1.0/PKG-INFO +284 -0
  9. verity_rag-0.1.0/README.md +239 -0
  10. verity_rag-0.1.0/alembic.ini +36 -0
  11. verity_rag-0.1.0/docker-compose.yml +182 -0
  12. verity_rag-0.1.0/frontend/css/style.css +782 -0
  13. verity_rag-0.1.0/frontend/index.html +80 -0
  14. verity_rag-0.1.0/frontend/js/api.js +123 -0
  15. verity_rag-0.1.0/frontend/js/app.js +867 -0
  16. verity_rag-0.1.0/manual_test_upload.py +68 -0
  17. verity_rag-0.1.0/plans/quirky-pondering-wilkes.md +291 -0
  18. verity_rag-0.1.0/pyproject.toml +61 -0
  19. verity_rag-0.1.0/rag_agent/__init__.py +3 -0
  20. verity_rag-0.1.0/rag_agent/app.py +108 -0
  21. verity_rag-0.1.0/rag_agent/chunkers/__init__.py +0 -0
  22. verity_rag-0.1.0/rag_agent/chunkers/base.py +26 -0
  23. verity_rag-0.1.0/rag_agent/chunkers/markdown.py +38 -0
  24. verity_rag-0.1.0/rag_agent/chunkers/recursive.py +36 -0
  25. verity_rag-0.1.0/rag_agent/connectors/__init__.py +0 -0
  26. verity_rag-0.1.0/rag_agent/connectors/base.py +106 -0
  27. verity_rag-0.1.0/rag_agent/core/__init__.py +0 -0
  28. verity_rag-0.1.0/rag_agent/core/config.py +148 -0
  29. verity_rag-0.1.0/rag_agent/core/database.py +83 -0
  30. verity_rag-0.1.0/rag_agent/core/deps.py +35 -0
  31. verity_rag-0.1.0/rag_agent/core/exceptions.py +59 -0
  32. verity_rag-0.1.0/rag_agent/core/logging.py +65 -0
  33. verity_rag-0.1.0/rag_agent/core/retry.py +63 -0
  34. verity_rag-0.1.0/rag_agent/core/valkey.py +50 -0
  35. verity_rag-0.1.0/rag_agent/db/__init__.py +6 -0
  36. verity_rag-0.1.0/rag_agent/db/base.py +9 -0
  37. verity_rag-0.1.0/rag_agent/db/migrations/__init__.py +0 -0
  38. verity_rag-0.1.0/rag_agent/db/migrations/env.py +72 -0
  39. verity_rag-0.1.0/rag_agent/db/models/__init__.py +6 -0
  40. verity_rag-0.1.0/rag_agent/db/models/document.py +62 -0
  41. verity_rag-0.1.0/rag_agent/db/models/sync_log.py +46 -0
  42. verity_rag-0.1.0/rag_agent/embeddings/__init__.py +0 -0
  43. verity_rag-0.1.0/rag_agent/embeddings/base.py +39 -0
  44. verity_rag-0.1.0/rag_agent/embeddings/openai_compat.py +50 -0
  45. verity_rag-0.1.0/rag_agent/embeddings/service.py +108 -0
  46. verity_rag-0.1.0/rag_agent/models/__init__.py +31 -0
  47. verity_rag-0.1.0/rag_agent/models/collection.py +20 -0
  48. verity_rag-0.1.0/rag_agent/models/common.py +25 -0
  49. verity_rag-0.1.0/rag_agent/models/document.py +84 -0
  50. verity_rag-0.1.0/rag_agent/models/ingestion.py +42 -0
  51. verity_rag-0.1.0/rag_agent/models/search.py +39 -0
  52. verity_rag-0.1.0/rag_agent/parsers/__init__.py +0 -0
  53. verity_rag-0.1.0/rag_agent/parsers/base.py +42 -0
  54. verity_rag-0.1.0/rag_agent/parsers/docx.py +34 -0
  55. verity_rag-0.1.0/rag_agent/parsers/pdf.py +201 -0
  56. verity_rag-0.1.0/rag_agent/parsers/registry.py +50 -0
  57. verity_rag-0.1.0/rag_agent/parsers/text.py +31 -0
  58. verity_rag-0.1.0/rag_agent/pipeline/__init__.py +0 -0
  59. verity_rag-0.1.0/rag_agent/pipeline/file_storage.py +57 -0
  60. verity_rag-0.1.0/rag_agent/pipeline/image_describer.py +84 -0
  61. verity_rag-0.1.0/rag_agent/pipeline/ingestion.py +250 -0
  62. verity_rag-0.1.0/rag_agent/pipeline/processor.py +131 -0
  63. verity_rag-0.1.0/rag_agent/repositories/__init__.py +0 -0
  64. verity_rag-0.1.0/rag_agent/repositories/document_repo.py +151 -0
  65. verity_rag-0.1.0/rag_agent/repositories/sync_log_repo.py +70 -0
  66. verity_rag-0.1.0/rag_agent/rerankers/__init__.py +0 -0
  67. verity_rag-0.1.0/rag_agent/rerankers/base.py +55 -0
  68. verity_rag-0.1.0/rag_agent/rerankers/service.py +18 -0
  69. verity_rag-0.1.0/rag_agent/retrieval/__init__.py +0 -0
  70. verity_rag-0.1.0/rag_agent/retrieval/bm25.py +29 -0
  71. verity_rag-0.1.0/rag_agent/retrieval/service.py +144 -0
  72. verity_rag-0.1.0/rag_agent/routes/__init__.py +0 -0
  73. verity_rag-0.1.0/rag_agent/routes/collections.py +98 -0
  74. verity_rag-0.1.0/rag_agent/routes/documents.py +146 -0
  75. verity_rag-0.1.0/rag_agent/routes/health.py +83 -0
  76. verity_rag-0.1.0/rag_agent/routes/search.py +146 -0
  77. verity_rag-0.1.0/rag_agent/routes/sync.py +113 -0
  78. verity_rag-0.1.0/rag_agent/schemas/__init__.py +0 -0
  79. verity_rag-0.1.0/rag_agent/schemas/collection.py +21 -0
  80. verity_rag-0.1.0/rag_agent/schemas/common.py +38 -0
  81. verity_rag-0.1.0/rag_agent/schemas/document.py +74 -0
  82. verity_rag-0.1.0/rag_agent/schemas/search.py +48 -0
  83. verity_rag-0.1.0/rag_agent/services/__init__.py +0 -0
  84. verity_rag-0.1.0/rag_agent/services/document_service.py +181 -0
  85. verity_rag-0.1.0/rag_agent/services/status_service.py +57 -0
  86. verity_rag-0.1.0/rag_agent/services/sync_service.py +105 -0
  87. verity_rag-0.1.0/rag_agent/vectorstore/__init__.py +0 -0
  88. verity_rag-0.1.0/rag_agent/vectorstore/base.py +134 -0
  89. verity_rag-0.1.0/rag_agent/vectorstore/milvus.py +181 -0
  90. verity_rag-0.1.0/rag_agent/vectorstore/service.py +66 -0
  91. verity_rag-0.1.0/rag_agent/worker/__init__.py +0 -0
  92. verity_rag-0.1.0/rag_agent/worker/dispatcher.py +35 -0
  93. verity_rag-0.1.0/rag_agent/worker/settings.py +155 -0
  94. verity_rag-0.1.0/run_server.sh +1 -0
  95. verity_rag-0.1.0/scripts/create_tables.py +33 -0
  96. verity_rag-0.1.0/scripts/run_migrations.py +42 -0
  97. verity_rag-0.1.0/scripts/wait_for_services.py +163 -0
  98. verity_rag-0.1.0/test_smoke.py +26 -0
  99. verity_rag-0.1.0/test_upload_logic.py +67 -0
  100. verity_rag-0.1.0/test_with_curl.sh +21 -0
  101. verity_rag-0.1.0/tests/__init__.py +0 -0
  102. verity_rag-0.1.0/tests/api/__init__.py +0 -0
  103. verity_rag-0.1.0/tests/api/test_documents.py +140 -0
  104. verity_rag-0.1.0/tests/conftest.py +88 -0
  105. verity_rag-0.1.0/tests/integration/__init__.py +0 -0
  106. verity_rag-0.1.0/tests/unit/__init__.py +0 -0
  107. 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