openqueryagent 1.0.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 (104) hide show
  1. openqueryagent-1.0.0/.github/ISSUE_TEMPLATE/bug_report.yml +50 -0
  2. openqueryagent-1.0.0/.github/ISSUE_TEMPLATE/feature_request.yml +23 -0
  3. openqueryagent-1.0.0/.github/ISSUE_TEMPLATE/new_adapter.yml +28 -0
  4. openqueryagent-1.0.0/.github/workflows/ci.yml +49 -0
  5. openqueryagent-1.0.0/.gitignore +42 -0
  6. openqueryagent-1.0.0/.pre-commit-config.yaml +26 -0
  7. openqueryagent-1.0.0/CONTRIBUTING.md +78 -0
  8. openqueryagent-1.0.0/Dockerfile +35 -0
  9. openqueryagent-1.0.0/PKG-INFO +432 -0
  10. openqueryagent-1.0.0/README.md +339 -0
  11. openqueryagent-1.0.0/docker-compose.yml +45 -0
  12. openqueryagent-1.0.0/openqueryagent/__init__.py +3 -0
  13. openqueryagent-1.0.0/openqueryagent/adapters/__init__.py +1 -0
  14. openqueryagent-1.0.0/openqueryagent/adapters/base.py +259 -0
  15. openqueryagent-1.0.0/openqueryagent/adapters/chroma.py +387 -0
  16. openqueryagent-1.0.0/openqueryagent/adapters/chroma_filters.py +128 -0
  17. openqueryagent-1.0.0/openqueryagent/adapters/elasticsearch.py +432 -0
  18. openqueryagent-1.0.0/openqueryagent/adapters/elasticsearch_filters.py +145 -0
  19. openqueryagent-1.0.0/openqueryagent/adapters/milvus.py +426 -0
  20. openqueryagent-1.0.0/openqueryagent/adapters/milvus_filters.py +189 -0
  21. openqueryagent-1.0.0/openqueryagent/adapters/pgvector.py +525 -0
  22. openqueryagent-1.0.0/openqueryagent/adapters/pgvector_filters.py +209 -0
  23. openqueryagent-1.0.0/openqueryagent/adapters/pinecone.py +315 -0
  24. openqueryagent-1.0.0/openqueryagent/adapters/pinecone_filters.py +126 -0
  25. openqueryagent-1.0.0/openqueryagent/adapters/qdrant.py +394 -0
  26. openqueryagent-1.0.0/openqueryagent/adapters/qdrant_filters.py +183 -0
  27. openqueryagent-1.0.0/openqueryagent/adapters/s3vectors.py +343 -0
  28. openqueryagent-1.0.0/openqueryagent/adapters/s3vectors_filters.py +127 -0
  29. openqueryagent-1.0.0/openqueryagent/adapters/weaviate.py +397 -0
  30. openqueryagent-1.0.0/openqueryagent/adapters/weaviate_filters.py +161 -0
  31. openqueryagent-1.0.0/openqueryagent/core/__init__.py +1 -0
  32. openqueryagent-1.0.0/openqueryagent/core/agent.py +399 -0
  33. openqueryagent-1.0.0/openqueryagent/core/circuit_breaker.py +162 -0
  34. openqueryagent-1.0.0/openqueryagent/core/config.py +38 -0
  35. openqueryagent-1.0.0/openqueryagent/core/exceptions.py +138 -0
  36. openqueryagent-1.0.0/openqueryagent/core/executor.py +267 -0
  37. openqueryagent-1.0.0/openqueryagent/core/filters.py +311 -0
  38. openqueryagent-1.0.0/openqueryagent/core/memory.py +108 -0
  39. openqueryagent-1.0.0/openqueryagent/core/planner.py +290 -0
  40. openqueryagent-1.0.0/openqueryagent/core/plugins.py +108 -0
  41. openqueryagent-1.0.0/openqueryagent/core/reranker.py +133 -0
  42. openqueryagent-1.0.0/openqueryagent/core/router.py +139 -0
  43. openqueryagent-1.0.0/openqueryagent/core/rule_planner.py +188 -0
  44. openqueryagent-1.0.0/openqueryagent/core/schema.py +166 -0
  45. openqueryagent-1.0.0/openqueryagent/core/synthesizer.py +216 -0
  46. openqueryagent-1.0.0/openqueryagent/core/types.py +340 -0
  47. openqueryagent-1.0.0/openqueryagent/embeddings/__init__.py +1 -0
  48. openqueryagent-1.0.0/openqueryagent/embeddings/base.py +62 -0
  49. openqueryagent-1.0.0/openqueryagent/embeddings/bedrock.py +125 -0
  50. openqueryagent-1.0.0/openqueryagent/embeddings/cohere.py +84 -0
  51. openqueryagent-1.0.0/openqueryagent/embeddings/huggingface.py +87 -0
  52. openqueryagent-1.0.0/openqueryagent/embeddings/openai.py +150 -0
  53. openqueryagent-1.0.0/openqueryagent/llm/__init__.py +1 -0
  54. openqueryagent-1.0.0/openqueryagent/llm/anthropic.py +241 -0
  55. openqueryagent-1.0.0/openqueryagent/llm/base.py +111 -0
  56. openqueryagent-1.0.0/openqueryagent/llm/bedrock.py +228 -0
  57. openqueryagent-1.0.0/openqueryagent/llm/ollama.py +142 -0
  58. openqueryagent-1.0.0/openqueryagent/llm/openai.py +195 -0
  59. openqueryagent-1.0.0/openqueryagent/observability/__init__.py +5 -0
  60. openqueryagent-1.0.0/openqueryagent/observability/metrics.py +126 -0
  61. openqueryagent-1.0.0/openqueryagent/observability/tracing.py +115 -0
  62. openqueryagent-1.0.0/openqueryagent/py.typed +0 -0
  63. openqueryagent-1.0.0/openqueryagent/server/__init__.py +8 -0
  64. openqueryagent-1.0.0/openqueryagent/server/__main__.py +43 -0
  65. openqueryagent-1.0.0/openqueryagent/server/api.py +417 -0
  66. openqueryagent-1.0.0/openqueryagent/server/config.py +65 -0
  67. openqueryagent-1.0.0/openqueryagent/server/dependencies.py +22 -0
  68. openqueryagent-1.0.0/openqueryagent/server/mcp_server.py +291 -0
  69. openqueryagent-1.0.0/openqueryagent/server/middleware.py +104 -0
  70. openqueryagent-1.0.0/openqueryagent/server/models.py +97 -0
  71. openqueryagent-1.0.0/openqueryagent/server/websocket.py +54 -0
  72. openqueryagent-1.0.0/pyproject.toml +162 -0
  73. openqueryagent-1.0.0/tests/__init__.py +1 -0
  74. openqueryagent-1.0.0/tests/test_adapters.py +290 -0
  75. openqueryagent-1.0.0/tests/test_agent.py +150 -0
  76. openqueryagent-1.0.0/tests/test_chroma_adapter.py +160 -0
  77. openqueryagent-1.0.0/tests/test_circuit_breaker.py +116 -0
  78. openqueryagent-1.0.0/tests/test_compilers.py +337 -0
  79. openqueryagent-1.0.0/tests/test_config.py +75 -0
  80. openqueryagent-1.0.0/tests/test_elasticsearch_adapter.py +138 -0
  81. openqueryagent-1.0.0/tests/test_embeddings.py +123 -0
  82. openqueryagent-1.0.0/tests/test_exceptions.py +97 -0
  83. openqueryagent-1.0.0/tests/test_executor.py +122 -0
  84. openqueryagent-1.0.0/tests/test_filters.py +262 -0
  85. openqueryagent-1.0.0/tests/test_llm_providers.py +79 -0
  86. openqueryagent-1.0.0/tests/test_mcp_server.py +91 -0
  87. openqueryagent-1.0.0/tests/test_memory.py +54 -0
  88. openqueryagent-1.0.0/tests/test_metrics.py +48 -0
  89. openqueryagent-1.0.0/tests/test_pinecone_adapter.py +122 -0
  90. openqueryagent-1.0.0/tests/test_planner.py +143 -0
  91. openqueryagent-1.0.0/tests/test_plugins.py +73 -0
  92. openqueryagent-1.0.0/tests/test_protocols.py +318 -0
  93. openqueryagent-1.0.0/tests/test_providers.py +238 -0
  94. openqueryagent-1.0.0/tests/test_reranker.py +82 -0
  95. openqueryagent-1.0.0/tests/test_router.py +110 -0
  96. openqueryagent-1.0.0/tests/test_rule_planner.py +107 -0
  97. openqueryagent-1.0.0/tests/test_s3vectors_adapter.py +120 -0
  98. openqueryagent-1.0.0/tests/test_schema.py +232 -0
  99. openqueryagent-1.0.0/tests/test_server.py +223 -0
  100. openqueryagent-1.0.0/tests/test_server_middleware.py +147 -0
  101. openqueryagent-1.0.0/tests/test_synthesizer.py +97 -0
  102. openqueryagent-1.0.0/tests/test_tracing.py +45 -0
  103. openqueryagent-1.0.0/tests/test_types.py +419 -0
  104. openqueryagent-1.0.0/tests/test_weaviate_adapter.py +108 -0
@@ -0,0 +1,50 @@
1
+ name: Bug Report
2
+ description: Report a bug or unexpected behavior
3
+ labels: [bug]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: Thank you for reporting a bug. Please fill out the details below.
8
+ - type: textarea
9
+ id: description
10
+ attributes:
11
+ label: Bug Description
12
+ description: A clear description of what the bug is.
13
+ validations:
14
+ required: true
15
+ - type: textarea
16
+ id: reproduction
17
+ attributes:
18
+ label: Steps to Reproduce
19
+ description: Steps to reproduce the behavior.
20
+ placeholder: |
21
+ 1. Configure adapter with...
22
+ 2. Call agent.ask("...")
23
+ 3. See error
24
+ validations:
25
+ required: true
26
+ - type: textarea
27
+ id: expected
28
+ attributes:
29
+ label: Expected Behavior
30
+ description: What you expected to happen.
31
+ validations:
32
+ required: true
33
+ - type: textarea
34
+ id: environment
35
+ attributes:
36
+ label: Environment
37
+ description: Version info
38
+ placeholder: |
39
+ - Python version: 3.12
40
+ - openqueryagent version: 0.3.0
41
+ - OS: Ubuntu 24.04
42
+ - Adapter: qdrant
43
+ validations:
44
+ required: true
45
+ - type: textarea
46
+ id: logs
47
+ attributes:
48
+ label: Relevant Logs
49
+ description: Paste any relevant log output (use code block).
50
+ render: shell
@@ -0,0 +1,23 @@
1
+ name: Feature Request
2
+ description: Suggest a new feature or improvement
3
+ labels: [enhancement]
4
+ body:
5
+ - type: textarea
6
+ id: problem
7
+ attributes:
8
+ label: Problem Statement
9
+ description: What problem does this feature solve?
10
+ validations:
11
+ required: true
12
+ - type: textarea
13
+ id: solution
14
+ attributes:
15
+ label: Proposed Solution
16
+ description: How should this work?
17
+ validations:
18
+ required: true
19
+ - type: textarea
20
+ id: alternatives
21
+ attributes:
22
+ label: Alternatives Considered
23
+ description: Any alternative approaches you've thought about.
@@ -0,0 +1,28 @@
1
+ name: New Adapter Proposal
2
+ description: Propose a new database adapter
3
+ labels: [adapter, enhancement]
4
+ body:
5
+ - type: textarea
6
+ id: database
7
+ attributes:
8
+ label: Database
9
+ description: Name and link to the database.
10
+ placeholder: "e.g. Redis Vector Search — https://redis.io/docs/stack/search/"
11
+ validations:
12
+ required: true
13
+ - type: textarea
14
+ id: justification
15
+ attributes:
16
+ label: Justification
17
+ description: Why should this adapter be added?
18
+ validations:
19
+ required: true
20
+ - type: dropdown
21
+ id: contributor
22
+ attributes:
23
+ label: Will you implement this?
24
+ options:
25
+ - "Yes, I'll submit a PR"
26
+ - "No, requesting someone else implement it"
27
+ validations:
28
+ required: true
@@ -0,0 +1,49 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ lint:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: actions/setup-python@v5
15
+ with:
16
+ python-version: "3.12"
17
+ - name: Install dependencies
18
+ run: pip install -e ".[dev]"
19
+ - name: Ruff check
20
+ run: ruff check openqueryagent/ tests/
21
+ - name: Ruff format check
22
+ run: ruff format --check openqueryagent/ tests/
23
+
24
+ type-check:
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - uses: actions/checkout@v4
28
+ - uses: actions/setup-python@v5
29
+ with:
30
+ python-version: "3.12"
31
+ - name: Install dependencies
32
+ run: pip install -e ".[dev]"
33
+ - name: Mypy
34
+ run: mypy openqueryagent/
35
+
36
+ test:
37
+ runs-on: ubuntu-latest
38
+ strategy:
39
+ matrix:
40
+ python-version: ["3.11", "3.12", "3.13"]
41
+ steps:
42
+ - uses: actions/checkout@v4
43
+ - uses: actions/setup-python@v5
44
+ with:
45
+ python-version: ${{ matrix.python-version }}
46
+ - name: Install dependencies
47
+ run: pip install -e ".[dev]"
48
+ - name: Run tests
49
+ run: pytest tests/ -v -m "not integration" --tb=short
@@ -0,0 +1,42 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+
7
+ # Distribution / packaging
8
+ dist/
9
+ build/
10
+ *.egg-info/
11
+ *.egg
12
+
13
+ # Virtual environments
14
+ .venv/
15
+ venv/
16
+ env/
17
+
18
+ # IDE
19
+ .idea/
20
+ .vscode/
21
+ *.swp
22
+ *.swo
23
+ *~
24
+
25
+ # Testing
26
+ .pytest_cache/
27
+ .coverage
28
+ htmlcov/
29
+ .mypy_cache/
30
+ .ruff_cache/
31
+
32
+ # OS
33
+ .DS_Store
34
+ Thumbs.db
35
+
36
+ # Environment
37
+ .env
38
+ .env.local
39
+
40
+ Design/
41
+ roadmap.md
42
+ ROADMAP.md
@@ -0,0 +1,26 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.4.8
4
+ hooks:
5
+ - id: ruff
6
+ args: [--fix]
7
+ - id: ruff-format
8
+
9
+ - repo: https://github.com/pre-commit/mirrors-mypy
10
+ rev: v1.10.0
11
+ hooks:
12
+ - id: mypy
13
+ additional_dependencies:
14
+ - pydantic>=2.0
15
+ args: [--strict]
16
+ pass_filenames: false
17
+ entry: mypy openqueryagent/
18
+
19
+ - repo: https://github.com/pre-commit/pre-commit-hooks
20
+ rev: v4.6.0
21
+ hooks:
22
+ - id: trailing-whitespace
23
+ - id: end-of-file-fixer
24
+ - id: check-yaml
25
+ - id: check-toml
26
+ - id: check-added-large-files
@@ -0,0 +1,78 @@
1
+ # Contributing to OpenQueryAgent
2
+
3
+ Thank you for your interest in contributing! This guide covers how to add new components, code style, and the PR process.
4
+
5
+ ## Development Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/thirukguru/openqueryagent.git
9
+ cd openqueryagent
10
+ python -m venv .venv && source .venv/bin/activate
11
+ pip install -e ".[dev,server,observability]"
12
+ pytest tests/ -v
13
+ ```
14
+
15
+ ## Adding a New Adapter
16
+
17
+ 1. **Create** `openqueryagent/adapters/my_db.py` inheriting from `BaseAdapter`
18
+ 2. **Implement** all abstract methods: `connect()`, `disconnect()`, `health_check()`, `search()`, `aggregate()`, `list_collections()`, `get_schema()`
19
+ 3. **Create** `openqueryagent/adapters/my_db_filters.py` with a `FilterCompiler` subclass
20
+ 4. **Add** an optional dependency group in `pyproject.toml`
21
+ 5. **Register** via entry point (optional, for plugin-based discovery):
22
+ ```toml
23
+ [project.entry-points."openqueryagent.adapters"]
24
+ my_db = "openqueryagent.adapters.my_db:MyDbAdapter"
25
+ ```
26
+ 6. **Write tests** in `tests/test_my_db_adapter.py`
27
+
28
+ ## Adding a New Reranker
29
+
30
+ 1. **Create** `openqueryagent/core/rerankers/my_reranker.py` implementing the `Reranker` protocol
31
+ 2. **Register** via entry point:
32
+ ```toml
33
+ [project.entry-points."openqueryagent.rerankers"]
34
+ my_reranker = "openqueryagent.core.rerankers.my_reranker:MyReranker"
35
+ ```
36
+
37
+ ## Adding a New LLM Provider
38
+
39
+ 1. **Create** `openqueryagent/llm/my_provider.py` inheriting from `BaseLLMProvider`
40
+ 2. **Add** optional dependency in `pyproject.toml`
41
+ 3. **Write tests** with mocked API responses
42
+
43
+ ## Code Style
44
+
45
+ - **Formatter & linter**: [Ruff](https://docs.astral.sh/ruff/) (`ruff check --fix . && ruff format .`)
46
+ - **Type checking**: [mypy](http://mypy-lang.org/) (`mypy openqueryagent/`)
47
+ - **Line length**: 100 characters
48
+ - **Docstrings**: Google style
49
+ - **Imports**: `from __future__ import annotations` at top of every module
50
+
51
+ ## Testing
52
+
53
+ ```bash
54
+ # Run all tests
55
+ pytest tests/ -v
56
+
57
+ # Run specific test file
58
+ pytest tests/test_my_adapter.py -v
59
+
60
+ # Run with coverage
61
+ pytest tests/ --cov=openqueryagent --cov-report=term-missing
62
+ ```
63
+
64
+ ## Pull Request Process
65
+
66
+ 1. Fork the repo and create a feature branch from `main`
67
+ 2. Keep commits focused and atomic
68
+ 3. Add tests for any new functionality
69
+ 4. Ensure all tests pass and linting is clean
70
+ 5. Update documentation if needed
71
+ 6. Submit PR with a clear description of what and why
72
+
73
+ ## Reporting Issues
74
+
75
+ Use the GitHub issue templates:
76
+ - **Bug Report** — reproducible bugs with environment details
77
+ - **Feature Request** — new feature proposals
78
+ - **New Adapter** — proposals for new database adapters
@@ -0,0 +1,35 @@
1
+ # ---- Build stage ----
2
+ FROM python:3.12-slim AS builder
3
+
4
+ WORKDIR /build
5
+
6
+ COPY pyproject.toml README.md ./
7
+ COPY openqueryagent/ ./openqueryagent/
8
+
9
+ RUN pip install --no-cache-dir build \
10
+ && python -m build --wheel --outdir /build/dist
11
+
12
+ # ---- Runtime stage ----
13
+ FROM python:3.12-slim
14
+
15
+ LABEL org.opencontainers.image.source="https://github.com/thirukguru/openqueryagent"
16
+ LABEL org.opencontainers.image.description="OpenQueryAgent — database-agnostic query agent for vector databases"
17
+
18
+ WORKDIR /app
19
+
20
+ # Install the wheel with server extras
21
+ COPY --from=builder /build/dist/*.whl /tmp/
22
+ RUN pip install --no-cache-dir /tmp/*.whl[server,openai,anthropic,qdrant,pgvector,milvus] \
23
+ && rm -rf /tmp/*.whl
24
+
25
+ # Non-root user
26
+ RUN useradd --create-home --shell /bin/bash oqa
27
+ USER oqa
28
+
29
+ EXPOSE 8000 50051
30
+
31
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
32
+ CMD python -c "import httpx; httpx.get('http://localhost:8000/v1/health').raise_for_status()"
33
+
34
+ ENTRYPOINT ["python", "-m", "openqueryagent.server"]
35
+ CMD ["--host", "0.0.0.0", "--port", "8000"]