ai-rag-common-framework 0.19.1__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 (124) hide show
  1. ai_rag_common_framework-0.19.1/.env.example +23 -0
  2. ai_rag_common_framework-0.19.1/.github/dependabot.yml +33 -0
  3. ai_rag_common_framework-0.19.1/.github/workflows/ci.yml +43 -0
  4. ai_rag_common_framework-0.19.1/.github/workflows/python-publish.yml +38 -0
  5. ai_rag_common_framework-0.19.1/.github/workflows/release.yml +35 -0
  6. ai_rag_common_framework-0.19.1/.github/workflows/sonar.yml +41 -0
  7. ai_rag_common_framework-0.19.1/.gitignore +66 -0
  8. ai_rag_common_framework-0.19.1/CHANGELOG.md +387 -0
  9. ai_rag_common_framework-0.19.1/LICENSE +21 -0
  10. ai_rag_common_framework-0.19.1/PKG-INFO +428 -0
  11. ai_rag_common_framework-0.19.1/README.md +374 -0
  12. ai_rag_common_framework-0.19.1/ROADMAP.md +127 -0
  13. ai_rag_common_framework-0.19.1/examples/basic/mcp_server_demo.py +64 -0
  14. ai_rag_common_framework-0.19.1/examples/basic/simple_completion.py +42 -0
  15. ai_rag_common_framework-0.19.1/examples/basic/simple_rag_demo.py +74 -0
  16. ai_rag_common_framework-0.19.1/examples/enterprise/conftest.py +14 -0
  17. ai_rag_common_framework-0.19.1/examples/enterprise/suite_1_gateway_lifecycle/__init__.py +1 -0
  18. ai_rag_common_framework-0.19.1/examples/enterprise/suite_1_gateway_lifecycle/gateway_app.py +74 -0
  19. ai_rag_common_framework-0.19.1/examples/enterprise/suite_1_gateway_lifecycle/test_gateway_lifecycle.py +110 -0
  20. ai_rag_common_framework-0.19.1/examples/enterprise/suite_2_auth_middleware/__init__.py +1 -0
  21. ai_rag_common_framework-0.19.1/examples/enterprise/suite_2_auth_middleware/auth_server.py +41 -0
  22. ai_rag_common_framework-0.19.1/examples/enterprise/suite_2_auth_middleware/test_auth_middleware.py +156 -0
  23. ai_rag_common_framework-0.19.1/examples/enterprise/suite_3_domain_isolation/__init__.py +1 -0
  24. ai_rag_common_framework-0.19.1/examples/enterprise/suite_3_domain_isolation/legal_service.py +87 -0
  25. ai_rag_common_framework-0.19.1/examples/enterprise/suite_3_domain_isolation/test_domain_isolation.py +144 -0
  26. ai_rag_common_framework-0.19.1/examples/enterprise/suite_4_fault_tolerance/__init__.py +1 -0
  27. ai_rag_common_framework-0.19.1/examples/enterprise/suite_4_fault_tolerance/gateway_resilience.py +56 -0
  28. ai_rag_common_framework-0.19.1/examples/enterprise/suite_4_fault_tolerance/test_fault_tolerance.py +145 -0
  29. ai_rag_common_framework-0.19.1/examples/enterprise/suite_5_mcp_protocol/__init__.py +1 -0
  30. ai_rag_common_framework-0.19.1/examples/enterprise/suite_5_mcp_protocol/mcp_rag_tool.py +95 -0
  31. ai_rag_common_framework-0.19.1/examples/enterprise/suite_5_mcp_protocol/test_mcp_protocol.py +159 -0
  32. ai_rag_common_framework-0.19.1/pyproject.toml +72 -0
  33. ai_rag_common_framework-0.19.1/scratch/close_p0_tasks.py +40 -0
  34. ai_rag_common_framework-0.19.1/scratch/verify_closed_pm.py +17 -0
  35. ai_rag_common_framework-0.19.1/sonar-project.properties +7 -0
  36. ai_rag_common_framework-0.19.1/src/common_framework/__init__.py +315 -0
  37. ai_rag_common_framework-0.19.1/src/common_framework/_version.py +3 -0
  38. ai_rag_common_framework-0.19.1/src/common_framework/agents/__init__.py +59 -0
  39. ai_rag_common_framework-0.19.1/src/common_framework/agents/hitl.py +143 -0
  40. ai_rag_common_framework-0.19.1/src/common_framework/agents/memory.py +138 -0
  41. ai_rag_common_framework-0.19.1/src/common_framework/agents/react.py +317 -0
  42. ai_rag_common_framework-0.19.1/src/common_framework/agents/supervisor.py +205 -0
  43. ai_rag_common_framework-0.19.1/src/common_framework/agents/workflow.py +188 -0
  44. ai_rag_common_framework-0.19.1/src/common_framework/api/__init__.py +33 -0
  45. ai_rag_common_framework-0.19.1/src/common_framework/api/app.py +253 -0
  46. ai_rag_common_framework-0.19.1/src/common_framework/api/mcp.py +126 -0
  47. ai_rag_common_framework-0.19.1/src/common_framework/api/routes/__init__.py +27 -0
  48. ai_rag_common_framework-0.19.1/src/common_framework/api/routes/rag.py +298 -0
  49. ai_rag_common_framework-0.19.1/src/common_framework/cli/__init__.py +16 -0
  50. ai_rag_common_framework-0.19.1/src/common_framework/cli/__main__.py +7 -0
  51. ai_rag_common_framework-0.19.1/src/common_framework/cli/doctor.py +313 -0
  52. ai_rag_common_framework-0.19.1/src/common_framework/cli/main.py +161 -0
  53. ai_rag_common_framework-0.19.1/src/common_framework/cli/repl.py +197 -0
  54. ai_rag_common_framework-0.19.1/src/common_framework/cli/scaffold.py +125 -0
  55. ai_rag_common_framework-0.19.1/src/common_framework/core/__init__.py +48 -0
  56. ai_rag_common_framework-0.19.1/src/common_framework/core/cache.py +386 -0
  57. ai_rag_common_framework-0.19.1/src/common_framework/core/config.py +129 -0
  58. ai_rag_common_framework-0.19.1/src/common_framework/core/deprecation.py +86 -0
  59. ai_rag_common_framework-0.19.1/src/common_framework/core/exceptions.py +123 -0
  60. ai_rag_common_framework-0.19.1/src/common_framework/core/llm.py +1157 -0
  61. ai_rag_common_framework-0.19.1/src/common_framework/core/security.py +67 -0
  62. ai_rag_common_framework-0.19.1/src/common_framework/eval/__init__.py +19 -0
  63. ai_rag_common_framework-0.19.1/src/common_framework/eval/hallucination.py +220 -0
  64. ai_rag_common_framework-0.19.1/src/common_framework/eval/triad.py +173 -0
  65. ai_rag_common_framework-0.19.1/src/common_framework/guardrails/__init__.py +27 -0
  66. ai_rag_common_framework-0.19.1/src/common_framework/guardrails/moderation.py +166 -0
  67. ai_rag_common_framework-0.19.1/src/common_framework/guardrails/sanitizer.py +298 -0
  68. ai_rag_common_framework-0.19.1/src/common_framework/mcp/__init__.py +17 -0
  69. ai_rag_common_framework-0.19.1/src/common_framework/mcp/client.py +420 -0
  70. ai_rag_common_framework-0.19.1/src/common_framework/mcp/server.py +223 -0
  71. ai_rag_common_framework-0.19.1/src/common_framework/observability/__init__.py +39 -0
  72. ai_rag_common_framework-0.19.1/src/common_framework/observability/cost.py +201 -0
  73. ai_rag_common_framework-0.19.1/src/common_framework/observability/metrics.py +120 -0
  74. ai_rag_common_framework-0.19.1/src/common_framework/observability/tracing.py +180 -0
  75. ai_rag_common_framework-0.19.1/src/common_framework/rag/__init__.py +62 -0
  76. ai_rag_common_framework-0.19.1/src/common_framework/rag/bm25.py +201 -0
  77. ai_rag_common_framework-0.19.1/src/common_framework/rag/embeddings.py +230 -0
  78. ai_rag_common_framework-0.19.1/src/common_framework/rag/engine.py +434 -0
  79. ai_rag_common_framework-0.19.1/src/common_framework/rag/models.py +43 -0
  80. ai_rag_common_framework-0.19.1/src/common_framework/rag/rerankers.py +255 -0
  81. ai_rag_common_framework-0.19.1/src/common_framework/rag/splitters.py +254 -0
  82. ai_rag_common_framework-0.19.1/src/common_framework/rag/sqlite_store.py +5 -0
  83. ai_rag_common_framework-0.19.1/src/common_framework/rag/storage/__init__.py +5 -0
  84. ai_rag_common_framework-0.19.1/src/common_framework/rag/storage/sqlite.py +496 -0
  85. ai_rag_common_framework-0.19.1/src/common_framework/rag/strategies.py +353 -0
  86. ai_rag_common_framework-0.19.1/src/common_framework/rag/vectorstore.py +541 -0
  87. ai_rag_common_framework-0.19.1/src/common_framework/tools/__init__.py +27 -0
  88. ai_rag_common_framework-0.19.1/src/common_framework/tools/base.py +158 -0
  89. ai_rag_common_framework-0.19.1/src/common_framework/tools/interpreter.py +229 -0
  90. ai_rag_common_framework-0.19.1/src/common_framework/tools/registry.py +65 -0
  91. ai_rag_common_framework-0.19.1/tests/__init__.py +1 -0
  92. ai_rag_common_framework-0.19.1/tests/test_agents.py +306 -0
  93. ai_rag_common_framework-0.19.1/tests/test_api_app.py +186 -0
  94. ai_rag_common_framework-0.19.1/tests/test_api_mcp.py +228 -0
  95. ai_rag_common_framework-0.19.1/tests/test_api_rag_routes.py +194 -0
  96. ai_rag_common_framework-0.19.1/tests/test_cli.py +302 -0
  97. ai_rag_common_framework-0.19.1/tests/test_code_interpreter.py +198 -0
  98. ai_rag_common_framework-0.19.1/tests/test_collections.py +123 -0
  99. ai_rag_common_framework-0.19.1/tests/test_config.py +49 -0
  100. ai_rag_common_framework-0.19.1/tests/test_edge_cases.py +599 -0
  101. ai_rag_common_framework-0.19.1/tests/test_embeddings_extended.py +164 -0
  102. ai_rag_common_framework-0.19.1/tests/test_eval.py +152 -0
  103. ai_rag_common_framework-0.19.1/tests/test_exceptions.py +38 -0
  104. ai_rag_common_framework-0.19.1/tests/test_fallback_llm.py +399 -0
  105. ai_rag_common_framework-0.19.1/tests/test_guardrails.py +158 -0
  106. ai_rag_common_framework-0.19.1/tests/test_hybrid_search.py +217 -0
  107. ai_rag_common_framework-0.19.1/tests/test_llm.py +308 -0
  108. ai_rag_common_framework-0.19.1/tests/test_mcp.py +70 -0
  109. ai_rag_common_framework-0.19.1/tests/test_mcp_client.py +345 -0
  110. ai_rag_common_framework-0.19.1/tests/test_observability.py +212 -0
  111. ai_rag_common_framework-0.19.1/tests/test_p0_fixes.py +269 -0
  112. ai_rag_common_framework-0.19.1/tests/test_rag.py +324 -0
  113. ai_rag_common_framework-0.19.1/tests/test_reranker.py +216 -0
  114. ai_rag_common_framework-0.19.1/tests/test_semantic_cache.py +306 -0
  115. ai_rag_common_framework-0.19.1/tests/test_splitters_streaming.py +122 -0
  116. ai_rag_common_framework-0.19.1/tests/test_sqlite_vectorstore.py +327 -0
  117. ai_rag_common_framework-0.19.1/tests/test_ssrf_security.py +65 -0
  118. ai_rag_common_framework-0.19.1/tests/test_strategies.py +273 -0
  119. ai_rag_common_framework-0.19.1/tests/test_streaming.py +291 -0
  120. ai_rag_common_framework-0.19.1/tests/test_supervisor.py +268 -0
  121. ai_rag_common_framework-0.19.1/tests/test_tools.py +140 -0
  122. ai_rag_common_framework-0.19.1/tests/test_vectorstore_perf.py +129 -0
  123. ai_rag_common_framework-0.19.1/tests/test_vectorstore_security.py +188 -0
  124. ai_rag_common_framework-0.19.1/tests/test_workflow.py +276 -0
@@ -0,0 +1,23 @@
1
+ # ==============================================================
2
+ # AI RAG Common Framework - Configuración de Entorno
3
+ # ==============================================================
4
+
5
+ # Entorno: development | staging | production
6
+ FRAMEWORK_ENV=development
7
+ LOG_LEVEL=INFO
8
+
9
+ # Proveedor por defecto: gemini | openai | anthropic | ollama
10
+ DEFAULT_LLM_PROVIDER=gemini
11
+ DEFAULT_LLM_MODEL=gemini-2.5-flash
12
+ DEFAULT_TEMPERATURE=0.7
13
+ DEFAULT_TIMEOUT_SECONDS=60.0
14
+ DEFAULT_MAX_RETRIES=3
15
+
16
+ # Llaves API de Proveedores (configura la que vayas a utilizar)
17
+ GEMINI_API_KEY=
18
+ OPENAI_API_KEY=
19
+ OPENAI_BASE_URL=https://api.openai.com/v1
20
+ ANTHROPIC_API_KEY=
21
+
22
+ # Ollama (si se usa localmente)
23
+ OLLAMA_BASE_URL=http://localhost:11434
@@ -0,0 +1,33 @@
1
+ version: 2
2
+ updates:
3
+ # Maintain Python dependencies defined in pyproject.toml
4
+ - package-ecosystem: "pip"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "weekly"
8
+ day: "monday"
9
+ time: "04:00"
10
+ timezone: "Etc/UTC"
11
+ open-pull-requests-limit: 10
12
+ labels:
13
+ - "dependencies"
14
+ - "python"
15
+ commit-message:
16
+ prefix: "deps"
17
+ include: "scope"
18
+
19
+ # Maintain GitHub Actions dependencies
20
+ - package-ecosystem: "github-actions"
21
+ directory: "/"
22
+ schedule:
23
+ interval: "weekly"
24
+ day: "monday"
25
+ time: "04:00"
26
+ timezone: "Etc/UTC"
27
+ open-pull-requests-limit: 10
28
+ labels:
29
+ - "dependencies"
30
+ - "github-actions"
31
+ commit-message:
32
+ prefix: "ci"
33
+ include: "scope"
@@ -0,0 +1,43 @@
1
+ name: Run tests and upload coverage
2
+
3
+ on:
4
+ push:
5
+ branches: [main, dev]
6
+ pull_request:
7
+ branches: [main, dev]
8
+
9
+ jobs:
10
+ test:
11
+ name: Run tests and collect coverage
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.2.2
16
+ with:
17
+ fetch-depth: 2
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
21
+ with:
22
+ python-version: "3.11"
23
+ cache: "pip"
24
+
25
+ - name: Install dependencies
26
+ run: |
27
+ python -m pip install --upgrade pip
28
+ python -m pip install -e ".[all]"
29
+
30
+ - name: Run tests
31
+ run: python -m pytest tests/ --cov=common_framework --cov-branch --cov-report=xml
32
+
33
+ - name: Upload results to Codecov
34
+ uses: codecov/codecov-action@0fb7174895f61a3b6b78fc075e0cd60383518dac # v5.4.0
35
+ with:
36
+ token: ${{ secrets.CODECOV_TOKEN }}
37
+ slug: buhozurdo/ai-rag-common-framework
38
+
39
+ - name: Upload test results to Codecov
40
+ if: ${{ !cancelled() }}
41
+ uses: codecov/test-results-action@0fa95f0e1eeaafde2c782583b36b28ad0d8c77d3 # v1.4.2
42
+ with:
43
+ token: ${{ secrets.CODECOV_TOKEN }}
@@ -0,0 +1,38 @@
1
+ name: Publish to Release
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: write
9
+
10
+ jobs:
11
+ build-and-release:
12
+ name: "Build and Attach Assets"
13
+ runs-on: "ubuntu-latest"
14
+
15
+ steps:
16
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.2.2
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
20
+ with:
21
+ python-version: "3.11"
22
+
23
+ - name: Install build tools and dependencies
24
+ run: |
25
+ python -m pip install --only-binary :all: --upgrade pip
26
+ python -m pip install --only-binary :all: build
27
+
28
+ - name: Build dists (.whl and .tar.gz)
29
+ run: |
30
+ SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) \
31
+ python -m build
32
+
33
+ - name: Upload binaries to GitHub Release
34
+ uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.2.1
35
+ with:
36
+ files: dist/*
37
+ env:
38
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,35 @@
1
+ name: Publish Python Package to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ pypi-publish:
9
+ name: Build and publish to PyPI
10
+ runs-on: ubuntu-latest
11
+ environment:
12
+ name: pypi
13
+ url: https://pypi.org/p/ai-rag-common-framework
14
+ permissions:
15
+ id-token: write # Obligatorio para la autenticación OIDC / Trusted Publisher
16
+
17
+ steps:
18
+ - name: Checkout repository
19
+ uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.2.2
20
+
21
+ - name: Set up Python
22
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
23
+ with:
24
+ python-version: "3.11"
25
+
26
+ - name: Install build tools
27
+ run: |
28
+ python -m pip install --only-binary :all: --upgrade pip
29
+ pip install --only-binary :all: build
30
+
31
+ - name: Build package source and wheel
32
+ run: python -m build
33
+
34
+ - name: Publish package to PyPI
35
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1
@@ -0,0 +1,41 @@
1
+ name: Build
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ pull_request:
7
+ types: [opened, synchronize, reopened]
8
+ jobs:
9
+ sonarqube:
10
+ name: SonarQube
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
14
+ with:
15
+ fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
19
+ with:
20
+ python-version: "3.11"
21
+ cache: "pip"
22
+
23
+ - name: Install dependencies
24
+ run: |
25
+ python -m pip install --upgrade pip
26
+ python -m pip install -e ".[all]"
27
+
28
+ - name: Run tests with coverage
29
+ run: python -m pytest tests/ --cov=common_framework --cov-branch --cov-report=xml
30
+
31
+ - name: Cache SonarQube packages
32
+ uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
33
+ with:
34
+ path: ~/.sonar/cache
35
+ key: ${{ runner.os }}-sonar
36
+ restore-keys: ${{ runner.os }}-sonar
37
+
38
+ - name: SonarQube Scan
39
+ uses: SonarSource/sonarqube-scan-action@4d1dc0c91ee400dcf8a6dddf2f705ac36542e304 # v8.4.0
40
+ env:
41
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
@@ -0,0 +1,66 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # Virtual environments
30
+ .venv
31
+ env/
32
+ venv/
33
+ ENV/
34
+ env.bak/
35
+ venv.bak/
36
+
37
+ # Environment variables
38
+ .env
39
+ .env.local
40
+ .env.*.local
41
+
42
+ # IDEs & Editors
43
+ .vscode/
44
+ .idea/
45
+ *.swp
46
+ *.swo
47
+
48
+ # Testing & Coverage
49
+ .pytest_cache/
50
+ .coverage
51
+ htmlcov/
52
+ .tox/
53
+ .nox/
54
+
55
+ # Database files
56
+ *.sqlite
57
+ *.sqlite3
58
+ *.db
59
+
60
+
61
+ # Local release guide
62
+ RELEASE.md
63
+
64
+ # Cache & tool artifacts
65
+ .rederive/
66
+