qaiss-sdk 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.
@@ -0,0 +1,207 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
203
+ Copyright 2026 QAISS
204
+ Licensed under the Apache License, Version 2.0 (the "License");
205
+ you may not use this file except in compliance with the License.
206
+ You may obtain a copy of the License at
207
+ http://www.apache.org/licenses/LICENSE-2.0
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: qaiss-sdk
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for QAISS — Non-blocking telemetry, observability, and passive auditing for AI agents and LLMs.
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://qaiss.com
7
+ Project-URL: Documentation, https://docs.qaiss.com
8
+ Project-URL: Repository, https://github.com/QodeRepo/qaiss-tools-sdk
9
+ Project-URL: Changelog, https://github.com/QodeRepo/qaiss-tools-sdk/blob/main/CHANGELOG.md
10
+ Project-URL: Issues, https://github.com/QodeRepo/qaiss-tools-sdk/issues
11
+ Keywords: llm,ai-agents,observability,telemetry,opentelemetry,guardrails,monitoring,hallucination-detection,fastapi,flask,django
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: System :: Monitoring
24
+ Classifier: Framework :: AsyncIO
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.8
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: opentelemetry-api>=1.20.0
30
+ Requires-Dist: opentelemetry-sdk>=1.20.0
31
+ Requires-Dist: httpx>=0.24.0
32
+ Requires-Dist: pydantic<3.0.0,>=1.10.0
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
35
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
36
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
37
+ Requires-Dist: respx>=0.20.0; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # QAISS SDK Monorepo (`QodeRepo-sdk`)
41
+
42
+ Welcome to the **QAISS SDK Monorepo**. This repository contains the lightweight, non-blocking client SDKs that power the **QAISS LLM Security & Observability Platform**.
43
+
44
+ ---
45
+
46
+ ## 🎯 The Mission
47
+ QAISS is a **Passive AI Auditing Platform**. It silently captures the exact JSON payloads returned by tools, databases, and APIs. This ground-truth data is evaluated by our backend 4-Stage Judge engine to provide clients with undeniable proof of:
48
+ 1. **Data Hallucinations:** When the LLM's response contradicts database facts.
49
+ 2. **Access Control Leaks (BOLA/IDOR):** When User A accesses data belonging to User B.
50
+ 3. **Broken Workflows:** When tools are executed in an unauthorized or invalid order.
51
+
52
+ ---
53
+
54
+ ## 📂 Repository Structure
55
+
56
+ ```text
57
+ QodeRepo-sdk/
58
+ ├── python/
59
+ │ ├── pyproject.toml # Packaging & build configuration (v0.1.0)
60
+ │ └── qaiss/
61
+ │ ├── __init__.py # 1-line init (`qaiss.init()`) & public exports
62
+ │ ├── core.py # Pure Python framework-agnostic request engine
63
+ │ ├── asgi.py # Universal ASGI 3.0 middleware (FastAPI, Litestar, Quart)
64
+ │ ├── wsgi.py # Universal WSGI PEP 3333 middleware (Flask, Bottle, Falcon)
65
+ │ ├── django_middleware.py # Django native middleware (with request.user visibility)
66
+ │ ├── middleware.py # Backward-compat shim
67
+ │ ├── client.py # QaissClient core runtime & lifecycle manager
68
+ │ ├── context.py # Async/thread-isolated ContextVar security context
69
+ │ ├── decorator.py # @client.track_tool & @client.track_agent decorators
70
+ │ ├── instrumentation.py # Universal choke-point monkey-patching & noise filtering
71
+ │ ├── models.py # Pydantic wire schema (QaissEventModel, SecurityContext)
72
+ │ ├── redaction.py # PII scrubber (Luhn credit cards, SSN, Emails, sensitive keys)
73
+ │ ├── truncation.py # Smart structural field-level payload truncator (64 KB)
74
+ │ └── transport.py # Non-blocking bounded background worker (micro-batching)
75
+ ├── tests/ # Comprehensive unit, integration, and concurrency test suite
76
+ ├── examples/ # Live runnable client examples
77
+ ├── docs/ # Architecture & client integration guides
78
+ ├── shared/
79
+ │ └── schema.json # Universal JSON Schema contract
80
+ └── README.md
81
+ ```
82
+
83
+ ---
84
+
85
+ ## 🌐 Framework Support: Universal Protocol Architecture
86
+
87
+ QAISS provides **framework independence** via protocol-level adapters built over a single, zero-dependency core engine (`QaissRequestEngine`):
88
+
89
+ ### 1. Universal Coverage (Zero SDK Code for New Frameworks)
90
+ - **`QaissASGIMiddleware` (ASGI 3.0)**: Supports **every** current and future ASGI framework (FastAPI, Starlette, Litestar, Quart, BlackSheep, Sanic, Django ASGI). Features immediate chunk passthrough so token-by-token streaming (SSE) is never delayed.
91
+ - **`QaissWSGIMiddleware` (WSGI PEP 3333)**: Supports **every** current and future WSGI framework (Flask, Bottle, Pyramid, Falcon, CherryPy, Django WSGI).
92
+
93
+ ### 2. Optional Enhanced Integration
94
+ - **`QaissDjangoMiddleware`**: A thin translator over `QaissRequestEngine` that extracts Django's post-auth `request.user` which is only visible within Django's internal middleware pipeline.
95
+
96
+ ---
97
+
98
+ ## 🚀 Quickstart (Python)
99
+
100
+ ### 1. Installation
101
+ ```bash
102
+ pip install qaiss-sdk
103
+ ```
104
+
105
+ ### 2. Framework-Independent Integration
106
+
107
+ #### A. FastAPI / Starlette / Litestar / Quart (ASGI)
108
+ ```python
109
+ from fastapi import FastAPI
110
+ import qaiss
111
+ from qaiss import QaissASGIMiddleware
112
+
113
+ app = FastAPI()
114
+ client = qaiss.init(api_key="your_api_key", environment="production")
115
+ app.add_middleware(QaissASGIMiddleware, qaiss_client=client)
116
+ ```
117
+
118
+ #### B. Flask / Bottle / Falcon / Pyramid (WSGI)
119
+ ```python
120
+ from flask import Flask
121
+ import qaiss
122
+ from qaiss import QaissWSGIMiddleware
123
+
124
+ app = Flask(__name__)
125
+ client = qaiss.init(api_key="your_api_key", environment="production")
126
+ app.wsgi_app = QaissWSGIMiddleware(app.wsgi_app, qaiss_client=client)
127
+ ```
128
+
129
+ #### C. Django (`settings.py`)
130
+ ```python
131
+ MIDDLEWARE = [
132
+ "django.middleware.security.SecurityMiddleware",
133
+ # ... other middlewares ...
134
+ "qaiss.django_middleware.QaissDjangoMiddleware", # ⬅️ Add 1 line
135
+ ]
136
+
137
+ QAISS_API_KEY = "your_api_key"
138
+ QAISS_ENVIRONMENT = "production"
139
+ ```
140
+
141
+ ---
142
+
143
+ ## ⚙️ Key Technical Guarantees
144
+ 1. **Zero-Touch Auto-Instrumentation:** Automatically intercepts LLMs (OpenAI, Anthropic, Gemini), Agent frameworks (Agno, LangChain, CrewAI, LlamaIndex), and HTTP calls (Requests, HTTPX).
145
+ 2. **Streaming Preserved:** ASGI streaming/SSE responses are forwarded immediately to clients with 0ms buffering delay.
146
+ 3. **Multi-Tenant Async Isolation:** Request-scoped `ContextVar` client resolution guarantees zero crosstalk across concurrent tenants.
147
+ 4. **Local PII Redaction:** Credit card numbers (Luhn-verified), SSNs, Emails, and secrets are scrubbed in-flight before leaving process memory.
148
+ 5. **Smart Structural Truncation:** Payloads are capped at 64 KB with cycle-safe ancestor stacks to prevent memory leaks and false-positive cycle errors.
@@ -0,0 +1,109 @@
1
+ # QAISS SDK Monorepo (`QodeRepo-sdk`)
2
+
3
+ Welcome to the **QAISS SDK Monorepo**. This repository contains the lightweight, non-blocking client SDKs that power the **QAISS LLM Security & Observability Platform**.
4
+
5
+ ---
6
+
7
+ ## 🎯 The Mission
8
+ QAISS is a **Passive AI Auditing Platform**. It silently captures the exact JSON payloads returned by tools, databases, and APIs. This ground-truth data is evaluated by our backend 4-Stage Judge engine to provide clients with undeniable proof of:
9
+ 1. **Data Hallucinations:** When the LLM's response contradicts database facts.
10
+ 2. **Access Control Leaks (BOLA/IDOR):** When User A accesses data belonging to User B.
11
+ 3. **Broken Workflows:** When tools are executed in an unauthorized or invalid order.
12
+
13
+ ---
14
+
15
+ ## 📂 Repository Structure
16
+
17
+ ```text
18
+ QodeRepo-sdk/
19
+ ├── python/
20
+ │ ├── pyproject.toml # Packaging & build configuration (v0.1.0)
21
+ │ └── qaiss/
22
+ │ ├── __init__.py # 1-line init (`qaiss.init()`) & public exports
23
+ │ ├── core.py # Pure Python framework-agnostic request engine
24
+ │ ├── asgi.py # Universal ASGI 3.0 middleware (FastAPI, Litestar, Quart)
25
+ │ ├── wsgi.py # Universal WSGI PEP 3333 middleware (Flask, Bottle, Falcon)
26
+ │ ├── django_middleware.py # Django native middleware (with request.user visibility)
27
+ │ ├── middleware.py # Backward-compat shim
28
+ │ ├── client.py # QaissClient core runtime & lifecycle manager
29
+ │ ├── context.py # Async/thread-isolated ContextVar security context
30
+ │ ├── decorator.py # @client.track_tool & @client.track_agent decorators
31
+ │ ├── instrumentation.py # Universal choke-point monkey-patching & noise filtering
32
+ │ ├── models.py # Pydantic wire schema (QaissEventModel, SecurityContext)
33
+ │ ├── redaction.py # PII scrubber (Luhn credit cards, SSN, Emails, sensitive keys)
34
+ │ ├── truncation.py # Smart structural field-level payload truncator (64 KB)
35
+ │ └── transport.py # Non-blocking bounded background worker (micro-batching)
36
+ ├── tests/ # Comprehensive unit, integration, and concurrency test suite
37
+ ├── examples/ # Live runnable client examples
38
+ ├── docs/ # Architecture & client integration guides
39
+ ├── shared/
40
+ │ └── schema.json # Universal JSON Schema contract
41
+ └── README.md
42
+ ```
43
+
44
+ ---
45
+
46
+ ## 🌐 Framework Support: Universal Protocol Architecture
47
+
48
+ QAISS provides **framework independence** via protocol-level adapters built over a single, zero-dependency core engine (`QaissRequestEngine`):
49
+
50
+ ### 1. Universal Coverage (Zero SDK Code for New Frameworks)
51
+ - **`QaissASGIMiddleware` (ASGI 3.0)**: Supports **every** current and future ASGI framework (FastAPI, Starlette, Litestar, Quart, BlackSheep, Sanic, Django ASGI). Features immediate chunk passthrough so token-by-token streaming (SSE) is never delayed.
52
+ - **`QaissWSGIMiddleware` (WSGI PEP 3333)**: Supports **every** current and future WSGI framework (Flask, Bottle, Pyramid, Falcon, CherryPy, Django WSGI).
53
+
54
+ ### 2. Optional Enhanced Integration
55
+ - **`QaissDjangoMiddleware`**: A thin translator over `QaissRequestEngine` that extracts Django's post-auth `request.user` which is only visible within Django's internal middleware pipeline.
56
+
57
+ ---
58
+
59
+ ## 🚀 Quickstart (Python)
60
+
61
+ ### 1. Installation
62
+ ```bash
63
+ pip install qaiss-sdk
64
+ ```
65
+
66
+ ### 2. Framework-Independent Integration
67
+
68
+ #### A. FastAPI / Starlette / Litestar / Quart (ASGI)
69
+ ```python
70
+ from fastapi import FastAPI
71
+ import qaiss
72
+ from qaiss import QaissASGIMiddleware
73
+
74
+ app = FastAPI()
75
+ client = qaiss.init(api_key="your_api_key", environment="production")
76
+ app.add_middleware(QaissASGIMiddleware, qaiss_client=client)
77
+ ```
78
+
79
+ #### B. Flask / Bottle / Falcon / Pyramid (WSGI)
80
+ ```python
81
+ from flask import Flask
82
+ import qaiss
83
+ from qaiss import QaissWSGIMiddleware
84
+
85
+ app = Flask(__name__)
86
+ client = qaiss.init(api_key="your_api_key", environment="production")
87
+ app.wsgi_app = QaissWSGIMiddleware(app.wsgi_app, qaiss_client=client)
88
+ ```
89
+
90
+ #### C. Django (`settings.py`)
91
+ ```python
92
+ MIDDLEWARE = [
93
+ "django.middleware.security.SecurityMiddleware",
94
+ # ... other middlewares ...
95
+ "qaiss.django_middleware.QaissDjangoMiddleware", # ⬅️ Add 1 line
96
+ ]
97
+
98
+ QAISS_API_KEY = "your_api_key"
99
+ QAISS_ENVIRONMENT = "production"
100
+ ```
101
+
102
+ ---
103
+
104
+ ## ⚙️ Key Technical Guarantees
105
+ 1. **Zero-Touch Auto-Instrumentation:** Automatically intercepts LLMs (OpenAI, Anthropic, Gemini), Agent frameworks (Agno, LangChain, CrewAI, LlamaIndex), and HTTP calls (Requests, HTTPX).
106
+ 2. **Streaming Preserved:** ASGI streaming/SSE responses are forwarded immediately to clients with 0ms buffering delay.
107
+ 3. **Multi-Tenant Async Isolation:** Request-scoped `ContextVar` client resolution guarantees zero crosstalk across concurrent tenants.
108
+ 4. **Local PII Redaction:** Credit card numbers (Luhn-verified), SSNs, Emails, and secrets are scrubbed in-flight before leaving process memory.
109
+ 5. **Smart Structural Truncation:** Payloads are capped at 64 KB with cycle-safe ancestor stacks to prevent memory leaks and false-positive cycle errors.
@@ -0,0 +1,66 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "qaiss-sdk"
7
+ version = "0.1.0"
8
+ description = "Official Python SDK for QAISS — Non-blocking telemetry, observability, and passive auditing for AI agents and LLMs."
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ requires-python = ">=3.8"
12
+
13
+ keywords = [
14
+ "llm",
15
+ "ai-agents",
16
+ "observability",
17
+ "telemetry",
18
+ "opentelemetry",
19
+ "guardrails",
20
+ "monitoring",
21
+ "hallucination-detection",
22
+ "fastapi",
23
+ "flask",
24
+ "django"
25
+ ]
26
+ classifiers = [
27
+ "Development Status :: 4 - Beta",
28
+ "Intended Audience :: Developers",
29
+ "Operating System :: OS Independent",
30
+ "Programming Language :: Python :: 3",
31
+ "Programming Language :: Python :: 3.8",
32
+ "Programming Language :: Python :: 3.9",
33
+ "Programming Language :: Python :: 3.10",
34
+ "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
36
+ "Programming Language :: Python :: 3.13",
37
+ "Topic :: Software Development :: Libraries :: Python Modules",
38
+ "Topic :: System :: Monitoring",
39
+ "Framework :: AsyncIO",
40
+ "Typing :: Typed"
41
+ ]
42
+ dependencies = [
43
+ "opentelemetry-api>=1.20.0",
44
+ "opentelemetry-sdk>=1.20.0",
45
+ "httpx>=0.24.0",
46
+ "pydantic>=1.10.0,<3.0.0"
47
+ ]
48
+
49
+ [project.urls]
50
+ Homepage = "https://qaiss.com"
51
+ Documentation = "https://docs.qaiss.com"
52
+ Repository = "https://github.com/QodeRepo/qaiss-tools-sdk"
53
+ Changelog = "https://github.com/QodeRepo/qaiss-tools-sdk/blob/main/CHANGELOG.md"
54
+ Issues = "https://github.com/QodeRepo/qaiss-tools-sdk/issues"
55
+
56
+ [project.optional-dependencies]
57
+ dev = [
58
+ "pytest>=7.0.0",
59
+ "pytest-asyncio>=0.21.0",
60
+ "mypy>=1.0.0",
61
+ "respx>=0.20.0"
62
+ ]
63
+
64
+ [tool.setuptools.packages.find]
65
+ where = ["."]
66
+ include = ["qaiss*"]
@@ -0,0 +1,70 @@
1
+ """
2
+ QAISS SDK: Production-grade Observability, Telemetry & Guardrails Client for AI Agents.
3
+ Collects and structures ground-truth telemetry for the QAISS Hallucination & Safety Evaluation Engine.
4
+ """
5
+
6
+ from typing import Optional, Any
7
+ from .client import QaissClient
8
+ from .context import set_context, get_current_security_context, clear_context, get_next_step_index
9
+ from .models import QaissEventModel, SecurityContext, LLMMetadata, EventType
10
+ from .redaction import scrub_payload, redact_string, is_valid_luhn
11
+ from .truncation import truncate_payload
12
+ from .core import QaissRequestEngine
13
+ from .asgi import QaissASGIMiddleware
14
+ from .wsgi import QaissWSGIMiddleware
15
+ from .django_middleware import QaissDjangoMiddleware
16
+ from .middleware import QaissMiddleware, QaissFastAPIMiddleware
17
+ from .instrumentation import wrap_tools, auto_instrument
18
+
19
+ __version__ = "0.1.0"
20
+ _global_client: Optional[QaissClient] = None
21
+
22
+ def init(
23
+ api_key: Optional[str] = None,
24
+ backend_url: Optional[str] = None,
25
+ environment: Optional[str] = None,
26
+ debug: bool = False,
27
+ **kwargs: Any
28
+ ) -> QaissClient:
29
+ """
30
+ Sentry-style single-line automatic initialization.
31
+ Automatically patches all AI libraries (OpenAI, Anthropic, Requests, HTTPX)
32
+ and Agent Framework constructors (Agno, LangChain, CrewAI, LlamaIndex) process-wide.
33
+ """
34
+ global _global_client
35
+ _global_client = QaissClient(
36
+ api_key=api_key,
37
+ backend_url=backend_url,
38
+ environment=environment,
39
+ debug=debug,
40
+ auto_track_libraries=True,
41
+ **kwargs
42
+ )
43
+ return _global_client
44
+
45
+ __all__ = [
46
+ "init",
47
+ "QaissClient",
48
+ "QaissRequestEngine",
49
+ "QaissASGIMiddleware",
50
+ "QaissWSGIMiddleware",
51
+ "QaissDjangoMiddleware",
52
+ "QaissMiddleware",
53
+ "QaissFastAPIMiddleware",
54
+ "wrap_tools",
55
+ "auto_instrument",
56
+ "set_context",
57
+ "get_current_security_context",
58
+ "clear_context",
59
+ "get_next_step_index",
60
+ "QaissEventModel",
61
+ "SecurityContext",
62
+ "LLMMetadata",
63
+ "EventType",
64
+ "scrub_payload",
65
+ "redact_string",
66
+ "is_valid_luhn",
67
+ "truncate_payload"
68
+ ]
69
+
70
+ __version__ = "0.1.0"