aaizaql 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 (71) hide show
  1. aaizaql-0.1.0/.github/workflows/ci.yml +103 -0
  2. aaizaql-0.1.0/.gitignore +94 -0
  3. aaizaql-0.1.0/.pre-commit-config.yaml +39 -0
  4. aaizaql-0.1.0/CONTRIBUTING.md +250 -0
  5. aaizaql-0.1.0/LICENSE +21 -0
  6. aaizaql-0.1.0/PKG-INFO +302 -0
  7. aaizaql-0.1.0/README.md +228 -0
  8. aaizaql-0.1.0/docs/api/engine.md +108 -0
  9. aaizaql-0.1.0/docs/getting-started/configuration.md +58 -0
  10. aaizaql-0.1.0/docs/getting-started/installation.md +71 -0
  11. aaizaql-0.1.0/docs/getting-started/quickstart.md +83 -0
  12. aaizaql-0.1.0/docs/guide/databases.md +136 -0
  13. aaizaql-0.1.0/docs/index.md +38 -0
  14. aaizaql-0.1.0/examples/01_quickstart_sqlite.py +140 -0
  15. aaizaql-0.1.0/examples/02_groq_end_to_end.py +308 -0
  16. aaizaql-0.1.0/examples/03_train_and_query.py +311 -0
  17. aaizaql-0.1.0/examples/quickstart_sqlite.py +130 -0
  18. aaizaql-0.1.0/mkdocs.yml +67 -0
  19. aaizaql-0.1.0/pyproject.toml +140 -0
  20. aaizaql-0.1.0/src/aaizaql/__init__.py +43 -0
  21. aaizaql-0.1.0/src/aaizaql/cli.py +159 -0
  22. aaizaql-0.1.0/src/aaizaql/connectors/__init__.py +53 -0
  23. aaizaql-0.1.0/src/aaizaql/connectors/base.py +68 -0
  24. aaizaql-0.1.0/src/aaizaql/connectors/duckdb.py +121 -0
  25. aaizaql-0.1.0/src/aaizaql/connectors/mysql.py +124 -0
  26. aaizaql-0.1.0/src/aaizaql/connectors/postgres.py +74 -0
  27. aaizaql-0.1.0/src/aaizaql/connectors/snowflake.py +188 -0
  28. aaizaql-0.1.0/src/aaizaql/connectors/sqlite.py +69 -0
  29. aaizaql-0.1.0/src/aaizaql/core/__init__.py +0 -0
  30. aaizaql-0.1.0/src/aaizaql/core/config.py +156 -0
  31. aaizaql-0.1.0/src/aaizaql/core/engine.py +308 -0
  32. aaizaql-0.1.0/src/aaizaql/core/exceptions.py +151 -0
  33. aaizaql-0.1.0/src/aaizaql/federation/__init__.py +0 -0
  34. aaizaql-0.1.0/src/aaizaql/llm/__init__.py +36 -0
  35. aaizaql-0.1.0/src/aaizaql/llm/base.py +38 -0
  36. aaizaql-0.1.0/src/aaizaql/llm/claude_provider.py +51 -0
  37. aaizaql-0.1.0/src/aaizaql/llm/groq_provider.py +99 -0
  38. aaizaql-0.1.0/src/aaizaql/llm/ollama_provider.py +54 -0
  39. aaizaql-0.1.0/src/aaizaql/llm/openai_provider.py +56 -0
  40. aaizaql-0.1.0/src/aaizaql/memory/__init__.py +0 -0
  41. aaizaql-0.1.0/src/aaizaql/memory/context.py +46 -0
  42. aaizaql-0.1.0/src/aaizaql/memory/vector_store.py +166 -0
  43. aaizaql-0.1.0/src/aaizaql/nlp/__init__.py +0 -0
  44. aaizaql-0.1.0/src/aaizaql/nlp/corrector.py +87 -0
  45. aaizaql-0.1.0/src/aaizaql/nlp/generator.py +195 -0
  46. aaizaql-0.1.0/src/aaizaql/nlp/prompts.py +124 -0
  47. aaizaql-0.1.0/src/aaizaql/schema/__init__.py +0 -0
  48. aaizaql-0.1.0/src/aaizaql/schema/ingestion.py +202 -0
  49. aaizaql-0.1.0/src/aaizaql/schema/semantic_store.py +202 -0
  50. aaizaql-0.1.0/src/aaizaql/security/__init__.py +0 -0
  51. aaizaql-0.1.0/src/aaizaql/security/audit.py +92 -0
  52. aaizaql-0.1.0/src/aaizaql/security/validator.py +208 -0
  53. aaizaql-0.1.0/src/aaizaql/visualization/__init__.py +0 -0
  54. aaizaql-0.1.0/src/aaizaql/visualization/renderer.py +126 -0
  55. aaizaql-0.1.0/src/aaizaql/visualization/summarizer.py +63 -0
  56. aaizaql-0.1.0/tests/__init__.py +0 -0
  57. aaizaql-0.1.0/tests/conftest.py +120 -0
  58. aaizaql-0.1.0/tests/integration/__init__.py +0 -0
  59. aaizaql-0.1.0/tests/integration/test_sqlite_pipeline.py +137 -0
  60. aaizaql-0.1.0/tests/test_connectors.py +492 -0
  61. aaizaql-0.1.0/tests/test_engine.py +135 -0
  62. aaizaql-0.1.0/tests/test_memory.py +69 -0
  63. aaizaql-0.1.0/tests/test_nlp.py +98 -0
  64. aaizaql-0.1.0/tests/test_schema.py +177 -0
  65. aaizaql-0.1.0/tests/test_security.py +143 -0
  66. aaizaql-0.1.0/tests/test_visualization.py +90 -0
  67. aaizaql-0.1.0/tests/unit/__init__.py +0 -0
  68. aaizaql-0.1.0/tests/unit/test_context.py +54 -0
  69. aaizaql-0.1.0/tests/unit/test_exceptions.py +73 -0
  70. aaizaql-0.1.0/tests/unit/test_semantic_store.py +195 -0
  71. aaizaql-0.1.0/tests/unit/test_validator.py +87 -0
@@ -0,0 +1,103 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, develop]
6
+ pull_request:
7
+ branches: [main, develop]
8
+
9
+ jobs:
10
+ lint:
11
+ name: Lint & Format
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: write
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ with:
18
+ token: ${{ secrets.GITHUB_TOKEN }}
19
+
20
+ - uses: actions/setup-python@v5
21
+ with:
22
+ python-version: "3.11"
23
+ cache: pip
24
+
25
+ - name: Install linting tools
26
+ run: pip install ruff black mypy
27
+
28
+ - name: Ruff auto-fix
29
+ run: ruff check src/ tests/ --fix --unsafe-fixes
30
+
31
+ - name: Black auto-format
32
+ run: black src/ tests/
33
+
34
+ - name: Commit fixes if needed
35
+ run: |
36
+ git config user.name "github-actions[bot]"
37
+ git config user.email "github-actions[bot]@users.noreply.github.com"
38
+ git diff --quiet && echo "No changes" || (git add -A && git commit -m "style: auto-fix ruff and black formatting")
39
+
40
+ - name: Push fixes
41
+ run: git push
42
+
43
+ - name: Ruff final check (must pass clean)
44
+ run: ruff check src/ tests/
45
+
46
+ test:
47
+ name: Tests (Python ${{ matrix.python-version }})
48
+ runs-on: ubuntu-latest
49
+ strategy:
50
+ fail-fast: false
51
+ matrix:
52
+ python-version: ["3.11", "3.12", "3.13"]
53
+
54
+ steps:
55
+ - uses: actions/checkout@v4
56
+
57
+ - uses: actions/setup-python@v5
58
+ with:
59
+ python-version: ${{ matrix.python-version }}
60
+ cache: pip
61
+
62
+ - name: Install package + dev dependencies
63
+ run: |
64
+ pip install -e ".[duckdb,mysql,snowflake]"
65
+ pip install pytest pytest-cov pytest-asyncio
66
+
67
+ - name: Run tests
68
+ run: pytest tests/ --cov=src/aaizaql --cov-report=term-missing
69
+
70
+ - name: Upload coverage report
71
+ uses: actions/upload-artifact@v4
72
+ if: matrix.python-version == '3.11'
73
+ with:
74
+ name: coverage-report
75
+ path: .coverage
76
+
77
+ build:
78
+ name: Build distribution
79
+ runs-on: ubuntu-latest
80
+ needs: [lint, test]
81
+ steps:
82
+ - uses: actions/checkout@v4
83
+
84
+ - uses: actions/setup-python@v5
85
+ with:
86
+ python-version: "3.11"
87
+ cache: pip
88
+
89
+ - name: Build wheel + sdist
90
+ run: |
91
+ pip install hatchling build
92
+ python -m build
93
+
94
+ - name: Check distribution metadata
95
+ run: |
96
+ pip install twine
97
+ twine check dist/*
98
+
99
+ - name: Upload build artifacts
100
+ uses: actions/upload-artifact@v4
101
+ with:
102
+ name: dist
103
+ path: dist/
@@ -0,0 +1,94 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ share/python-wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+ MANIFEST
24
+
25
+ # Virtual environments
26
+ .env
27
+ .venv
28
+ env/
29
+ venv/
30
+ ENV/
31
+ env.bak/
32
+ venv.bak/
33
+
34
+ # Secrets / credentials
35
+ .env.local
36
+ .env.production
37
+ secrets.toml
38
+
39
+ # Testing
40
+ .tox/
41
+ .nox/
42
+ .coverage
43
+ .coverage.*
44
+ .cache
45
+ coverage.xml
46
+ *.cover
47
+ *.py,cover
48
+ .hypothesis/
49
+ .pytest_cache/
50
+ pytestdebug.log
51
+
52
+ # Type checking
53
+ .mypy_cache/
54
+ .dmypy.json
55
+ dmypy.json
56
+
57
+ # Jupyter
58
+ .ipynb_checkpoints
59
+ *.ipynb_checkpoints
60
+
61
+ # Vector store data (local dev)
62
+ .nlsql_chroma/
63
+ .chroma/
64
+
65
+ # IDEs
66
+ .vscode/
67
+ .idea/
68
+ *.swp
69
+ *.swo
70
+ *~
71
+ .DS_Store
72
+
73
+ # Distribution
74
+ *.tar.gz
75
+ *.whl
76
+
77
+ # Docs build
78
+ docs/_build/
79
+ site/
80
+
81
+ # Logs
82
+ *.log
83
+ audit_*.jsonl
84
+
85
+ *.db
86
+ .aqlix_chroma/
87
+
88
+ aqlix.zip
89
+ *.zip
90
+
91
+ .pypirc
92
+ *.pem
93
+ *.key
94
+ .pypirc
@@ -0,0 +1,39 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v4.6.0
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ - id: end-of-file-fixer
7
+ - id: check-yaml
8
+ - id: check-toml
9
+ - id: check-json
10
+ - id: check-merge-conflict
11
+ - id: check-added-large-files
12
+ args: ["--maxkb=500"]
13
+ - id: debug-statements
14
+ - id: no-commit-to-branch
15
+ args: ["--branch", "main"]
16
+
17
+ - repo: https://github.com/psf/black
18
+ rev: 24.4.2
19
+ hooks:
20
+ - id: black
21
+ language_version: python3.11
22
+
23
+ - repo: https://github.com/PyCQA/flake8
24
+ rev: 7.0.0
25
+ hooks:
26
+ - id: flake8
27
+ args:
28
+ - "--max-line-length=100"
29
+ - "--extend-ignore=E203,W503"
30
+ - "--exclude=.git,__pycache__,.venv,build,dist"
31
+
32
+ - repo: https://github.com/pre-commit/mirrors-mypy
33
+ rev: v1.9.0
34
+ hooks:
35
+ - id: mypy
36
+ additional_dependencies:
37
+ - pydantic>=2.0
38
+ - pydantic-settings>=2.0
39
+ args: ["--ignore-missing-imports"]
@@ -0,0 +1,250 @@
1
+ # Contributing to AAIZAQL
2
+
3
+ Contributions are welcome — bug fixes, new connectors, LLM providers, docs, and tests all help.
4
+ This guide covers everything you need to go from zero to a merged pull request.
5
+
6
+ ---
7
+
8
+ ## Table of contents
9
+
10
+ - [Getting started](#getting-started)
11
+ - [Project structure](#project-structure)
12
+ - [Running tests](#running-tests)
13
+ - [Code style](#code-style)
14
+ - [Types of contributions](#types-of-contributions)
15
+ - [Pull request process](#pull-request-process)
16
+ - [Commit message format](#commit-message-format)
17
+ - [Reporting bugs](#reporting-bugs)
18
+
19
+ ---
20
+
21
+ ## Getting started
22
+
23
+ **Requirements:** Python 3.11+, Git.
24
+
25
+ ```bash
26
+ git clone https://github.com/ibrahimkhalilCorp/AAIZAQL
27
+ cd AAIZAQL
28
+ pip install -e ".[dev]"
29
+ pre-commit install
30
+ ```
31
+
32
+ That installs the library in editable mode with all dev dependencies (pytest, black, ruff, mypy)
33
+ and registers the pre-commit hooks so formatting runs automatically before every commit.
34
+
35
+ Verify the setup works:
36
+
37
+ ```bash
38
+ pytest tests/unit/ # fast, no API key needed
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Project structure
44
+
45
+ ```
46
+ src/AAIZAQL/
47
+ ├── core/ # QueryEngine, Settings, exceptions — the public API
48
+ ├── nlp/ # SQLGenerator, SelfCorrector, prompts
49
+ ├── memory/ # ContextManager, VectorStoreAdapter
50
+ ├── security/ # SQLValidator, AuditLogger
51
+ ├── connectors/ # One file per database (sqlite, postgres, mysql, …)
52
+ ├── llm/ # One file per LLM provider (claude, openai, groq, ollama)
53
+ ├── federation/ # FederationCoordinator, QueryPlanner (Phase 3)
54
+ ├── schema/ # SchemaIngester, SemanticLayer
55
+ ├── visualization/ # ResultRenderer, NLSummarizer
56
+ └── cli.py # `AAIZAQL` command-line entry point
57
+ tests/
58
+ ├── unit/ # Pure unit tests — no DB, no API key, always fast
59
+ ├── integration/ # Tests against a real SQLite database
60
+ └── conftest.py # Shared fixtures (sqlite_db, mock_llm, vector_store, …)
61
+ ```
62
+
63
+ The most important rule: **every layer has one job.**
64
+ The NLP layer produces SQL. The security layer validates it. The execution layer runs it.
65
+ Never mix concerns across layers.
66
+
67
+ ---
68
+
69
+ ## Running tests
70
+
71
+ ```bash
72
+ # Unit tests only (fast, no external deps)
73
+ pytest tests/unit/
74
+
75
+ # Full test suite (requires chromadb and sentence-transformers)
76
+ pytest tests/
77
+
78
+ # With coverage report
79
+ pytest tests/ --cov=src/AAIZAQL --cov-report=term-missing
80
+
81
+ # Run a specific file
82
+ pytest tests/unit/test_validator.py -v
83
+ ```
84
+
85
+ Tests marked `@pytest.mark.requires_api_key` are automatically skipped when no
86
+ `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` environment variable is set. To run them locally:
87
+
88
+ ```bash
89
+ export AAIZAQL_GROQ_API_KEY="gsk_..."
90
+ pytest tests/ -m requires_api_key
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Code style
96
+
97
+ The CI pipeline enforces all of these automatically. Running `pre-commit install` means
98
+ they also run locally before every commit.
99
+
100
+ | Tool | What it does | Config |
101
+ |---|---|---|
102
+ | `black` | Formats code | `pyproject.toml` → `[tool.black]` |
103
+ | `ruff` | Lints and auto-fixes | `pyproject.toml` → `[tool.ruff]` |
104
+ | `mypy` | Type-checks (non-strict) | `pyproject.toml` → `[tool.mypy]` |
105
+
106
+ Line length is **100 characters**. Use type hints everywhere. Avoid bare `Exception` —
107
+ raise the specific exception from `AAIZAQL.core.exceptions` that matches the failure.
108
+
109
+ To run checks manually:
110
+
111
+ ```bash
112
+ black src/ tests/
113
+ ruff check src/ tests/ --fix
114
+ mypy src/
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Types of contributions
120
+
121
+ ### Adding a new database connector
122
+
123
+ 1. Create `src/AAIZAQL/connectors/<name>.py` — subclass `DatabaseConnector` and implement
124
+ `connect()`, `execute()`, `get_schema()`, and `close()`. Follow the pattern in
125
+ `connectors/sqlite.py` or `connectors/postgres.py`.
126
+
127
+ 2. Add a lazy-import block in `src/AAIZAQL/connectors/__init__.py`:
128
+
129
+ ```python
130
+ try:
131
+ from AAIZAQL.connectors.bigquery import BigQueryConnector
132
+ REGISTRY["bigquery"] = BigQueryConnector
133
+ except ImportError:
134
+ pass
135
+ ```
136
+
137
+ 3. Add the driver to `pyproject.toml` as an optional dependency:
138
+
139
+ ```toml
140
+ [project.optional-dependencies]
141
+ bigquery = ["google-cloud-bigquery>=3.0"]
142
+ ```
143
+
144
+ 4. Write tests in `tests/test_connectors.py` following the existing pattern.
145
+
146
+ ### Adding a new LLM provider
147
+
148
+ 1. Create `src/AAIZAQL/llm/<name>_provider.py` — subclass `LLMProvider` and implement
149
+ `complete()`. Follow the pattern in `llm/groq_provider.py`.
150
+
151
+ 2. Register it in `src/AAIZAQL/llm/__init__.py`.
152
+
153
+ 3. Add the SDK to `pyproject.toml` as an optional dependency.
154
+
155
+ 4. Update the `Supported LLM Providers` table in `README.md`.
156
+
157
+ ### Fixing a bug
158
+
159
+ - Open an issue first if the fix is non-trivial, so we can agree on the approach.
160
+ - Include a failing test that reproduces the bug in your PR.
161
+ - The fix and the test should be in the same commit.
162
+
163
+ ### Improving documentation
164
+
165
+ - Docs changes (README, docstrings, examples) are always welcome without an issue first.
166
+ - Example notebooks live in `examples/` — follow the naming convention
167
+ `NN_short_description.py` (e.g. `04_snowflake_quickstart.py`).
168
+
169
+ ---
170
+
171
+ ## Pull request process
172
+
173
+ 1. **Fork** the repo and create a branch from `main`:
174
+
175
+ ```bash
176
+ git checkout -b feat/bigquery-connector
177
+ ```
178
+
179
+ 2. **Write tests** for your change. PRs without tests for new behaviour will be asked
180
+ to add them before merging.
181
+
182
+ 3. **Make sure CI passes** locally before pushing:
183
+
184
+ ```bash
185
+ pytest tests/unit/
186
+ ruff check src/ tests/
187
+ black --check src/ tests/
188
+ ```
189
+
190
+ 4. **Open a PR** against `main`. Fill in the PR template:
191
+ - What does this change?
192
+ - Why is it needed?
193
+ - How was it tested?
194
+
195
+ 5. **One approval** from a maintainer is required to merge. Small fixes (typos, docs)
196
+ can be merged by a maintainer directly.
197
+
198
+ 6. Squash-merge is preferred for feature branches to keep the `main` history clean.
199
+
200
+ ---
201
+
202
+ ## Commit message format
203
+
204
+ Use [Conventional Commits](https://www.conventionalcommits.org/):
205
+
206
+ ```
207
+ <type>: <short summary in sentence case>
208
+
209
+ <optional body explaining why, not what>
210
+ ```
211
+
212
+ Common types:
213
+
214
+ | Type | When to use |
215
+ |---|---|
216
+ | `feat` | New feature or connector |
217
+ | `fix` | Bug fix |
218
+ | `test` | Adding or fixing tests |
219
+ | `docs` | Documentation only |
220
+ | `style` | Formatting, no logic change |
221
+ | `refactor` | Code change with no behaviour change |
222
+ | `chore` | Build scripts, CI, dependencies |
223
+
224
+ Examples:
225
+
226
+ ```
227
+ feat: add BigQuery connector
228
+ fix: handle empty result set in NLSummarizer
229
+ docs: add Snowflake quickstart example
230
+ test: add unit tests for MySQLConnector DSN parser
231
+ ```
232
+
233
+ ---
234
+
235
+ ## Reporting bugs
236
+
237
+ Open a [GitHub issue](https://github.com/ibrahimkhalilCorp/AAIZAQL/issues) and include:
238
+
239
+ - AAIZAQL version (`pip show AAIZAQL`)
240
+ - Python version (`python --version`)
241
+ - Database and LLM provider being used
242
+ - The question you asked and the SQL that was generated (if any)
243
+ - The full error traceback
244
+
245
+ For security vulnerabilities, do **not** open a public issue.
246
+ Email the maintainer directly (see the `authors` field in `pyproject.toml`).
247
+
248
+ ---
249
+
250
+ MIT License — by contributing you agree your work will be released under the same license.
aaizaql-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ibrahim Khalil
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.