kubemind 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,83 @@
1
+ Metadata-Version: 2.4
2
+ Name: kubemind
3
+ Version: 0.1.0
4
+ Summary: Official Python client SDK for KubeMind AI Gateway and Governance Control Plane
5
+ Author: KubeMind team
6
+ Author-email: KubeMind Team <maintainers@kubemind.io>
7
+ License: MIT
8
+ Project-URL: Homepage, https://kubemind.io
9
+ Project-URL: Documentation, https://kubemind.io/docs
10
+ Project-URL: Repository, https://github.com/kubemind/kubemind
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Security
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ Requires-Dist: httpx>=0.23.0
25
+ Dynamic: author
26
+ Dynamic: requires-python
27
+
28
+ # KubeMind Python SDK (`kubemind`)
29
+
30
+ The official Python client library for **KubeMind** — the self-hosted intelligent AI gateway and governance control plane.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install kubemind
36
+ ```
37
+
38
+ ## Quickstart
39
+
40
+ ```python
41
+ from kubemind import KubeMindClient
42
+
43
+ # Initialize client with API key and workspace ID
44
+ client = KubeMindClient(
45
+ api_key="your-api-key",
46
+ workspace_id="default",
47
+ router_url="http://localhost:9080",
48
+ mind_url="http://localhost:9081",
49
+ sentinel_url="http://localhost:9083",
50
+ )
51
+
52
+ # 1. Chat completion with intent classification & sensitivity governance
53
+ completion = client.chat_completion(
54
+ model="llama3.1",
55
+ messages=[
56
+ {"role": "user", "content": "Email alice@example.com the summary report"}
57
+ ]
58
+ )
59
+ print("Response:", completion["choices"][0]["message"]["content"])
60
+ print("Routing Decision:", completion.get("routing_decision"))
61
+
62
+ # 2. Semantic prompt routing
63
+ route = client.route("What is our company expense policy?")
64
+ print("Content:", route.get("content"))
65
+ print("Retrieval Status:", route.get("retrieval_status"))
66
+
67
+ # 3. CFO Cost & Usage Analytics
68
+ analytics = client.get_cost_analytics(window_hours=24)
69
+ print(f"Total Requests: {analytics['total_requests']}")
70
+ print(f"Estimated Spend ($): {analytics['estimated_spend_usd']}")
71
+
72
+ # 4. Cryptographic Ledger Verification
73
+ audit = client.verify_audit_ledger()
74
+ print("Ledger Intact:", audit.get("verified"))
75
+ ```
76
+
77
+ ## Features
78
+
79
+ - **Pre-Dispatch Sensitivity Gating**: Inline regex + local offline NER tokenization with in-memory reversible restoration.
80
+ - **Intent-Driven Routing**: Routes prompts dynamically based on classified semantic intent.
81
+ - **Fail-Closed Grounding**: Distinguishes verified corporate knowledge from hallucinations.
82
+ - **SHA-256 Tamper-Evident Ledger**: Verifiable cryptographic audit trail for HIPAA/SOC2 compliance.
83
+ - **Granular RBAC**: Supports role-scoped API keys (`admin`, `developer`, `auditor`, `viewer`).
@@ -0,0 +1,56 @@
1
+ # KubeMind Python SDK (`kubemind`)
2
+
3
+ The official Python client library for **KubeMind** — the self-hosted intelligent AI gateway and governance control plane.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install kubemind
9
+ ```
10
+
11
+ ## Quickstart
12
+
13
+ ```python
14
+ from kubemind import KubeMindClient
15
+
16
+ # Initialize client with API key and workspace ID
17
+ client = KubeMindClient(
18
+ api_key="your-api-key",
19
+ workspace_id="default",
20
+ router_url="http://localhost:9080",
21
+ mind_url="http://localhost:9081",
22
+ sentinel_url="http://localhost:9083",
23
+ )
24
+
25
+ # 1. Chat completion with intent classification & sensitivity governance
26
+ completion = client.chat_completion(
27
+ model="llama3.1",
28
+ messages=[
29
+ {"role": "user", "content": "Email alice@example.com the summary report"}
30
+ ]
31
+ )
32
+ print("Response:", completion["choices"][0]["message"]["content"])
33
+ print("Routing Decision:", completion.get("routing_decision"))
34
+
35
+ # 2. Semantic prompt routing
36
+ route = client.route("What is our company expense policy?")
37
+ print("Content:", route.get("content"))
38
+ print("Retrieval Status:", route.get("retrieval_status"))
39
+
40
+ # 3. CFO Cost & Usage Analytics
41
+ analytics = client.get_cost_analytics(window_hours=24)
42
+ print(f"Total Requests: {analytics['total_requests']}")
43
+ print(f"Estimated Spend ($): {analytics['estimated_spend_usd']}")
44
+
45
+ # 4. Cryptographic Ledger Verification
46
+ audit = client.verify_audit_ledger()
47
+ print("Ledger Intact:", audit.get("verified"))
48
+ ```
49
+
50
+ ## Features
51
+
52
+ - **Pre-Dispatch Sensitivity Gating**: Inline regex + local offline NER tokenization with in-memory reversible restoration.
53
+ - **Intent-Driven Routing**: Routes prompts dynamically based on classified semantic intent.
54
+ - **Fail-Closed Grounding**: Distinguishes verified corporate knowledge from hallucinations.
55
+ - **SHA-256 Tamper-Evident Ledger**: Verifiable cryptographic audit trail for HIPAA/SOC2 compliance.
56
+ - **Granular RBAC**: Supports role-scoped API keys (`admin`, `developer`, `auditor`, `viewer`).
@@ -0,0 +1,3 @@
1
+ from .client import KubeMindClient
2
+
3
+ __all__ = ["KubeMindClient"]
@@ -0,0 +1,169 @@
1
+ import os
2
+ import httpx
3
+ from typing import List, Dict, Any, Optional
4
+
5
+ class KubeMindClient:
6
+ """
7
+ Official Python SDK client for KubeMind.
8
+ Provides standard wrappers around KubeMind services (Router, Mind, Sentinel).
9
+ """
10
+ def __init__(
11
+ self,
12
+ api_key: Optional[str] = None,
13
+ workspace_id: Optional[str] = None,
14
+ router_url: Optional[str] = None,
15
+ mind_url: Optional[str] = None,
16
+ sentinel_url: Optional[str] = None,
17
+ timeout: float = 30.0
18
+ ):
19
+ self.workspace_id = workspace_id or os.environ.get("KUBEMIND_WORKSPACE", "default")
20
+ resolved_router = router_url or os.environ.get("ROUTER_URL", os.environ.get("KUBEMIND_ROUTER_URL", "http://localhost:9080"))
21
+ resolved_mind = mind_url or os.environ.get("MIND_URL", os.environ.get("KUBEMIND_MIND_URL", "http://localhost:9081"))
22
+ resolved_sentinel = sentinel_url or os.environ.get("SENTINEL_URL", os.environ.get("KUBEMIND_SENTINEL_URL", "http://localhost:9083"))
23
+
24
+ self.router_url = resolved_router.rstrip("/")
25
+ self.mind_url = resolved_mind.rstrip("/")
26
+ self.sentinel_url = resolved_sentinel.rstrip("/")
27
+ self.timeout = timeout
28
+
29
+ self.headers = {
30
+ "Content-Type": "application/json",
31
+ "X-Workspace-ID": self.workspace_id
32
+ }
33
+ if api_key:
34
+ self.headers["X-API-Key"] = api_key
35
+
36
+ def chat_completion(self, model: str, messages: List[Dict[str, str]], enable_cache: bool = True, **kwargs) -> Dict[str, Any]:
37
+ """
38
+ Sends a prompt to the KubeMind Router for classification, policy overlay, and LLM completions.
39
+ """
40
+ url = f"{self.router_url}/v1/chat/completions"
41
+ payload = {
42
+ "model": model,
43
+ "messages": messages,
44
+ "enable_cache": enable_cache,
45
+ **kwargs
46
+ }
47
+ with httpx.Client(timeout=self.timeout) as client:
48
+ resp = client.post(url, headers=self.headers, json=payload)
49
+ resp.raise_for_status()
50
+ return resp.json()
51
+
52
+ def chat_stream(self, model: str, messages: List[Dict[str, str]], **kwargs):
53
+ """
54
+ Stream chat completion tokens in real-time with de-anonymization applied.
55
+ """
56
+ import json
57
+ url = f"{self.router_url}/v1/chat/completions"
58
+ payload = {
59
+ "model": model,
60
+ "messages": messages,
61
+ "stream": True,
62
+ **kwargs
63
+ }
64
+ with httpx.Client(timeout=self.timeout) as client:
65
+ with client.stream("POST", url, headers=self.headers, json=payload) as resp:
66
+ resp.raise_for_status()
67
+ for line in resp.iter_lines():
68
+ if line.startswith("data: ") and not line.startswith("data: [DONE]"):
69
+ try:
70
+ yield json.loads(line[6:])
71
+ except Exception:
72
+ continue
73
+
74
+ def route(self, prompt: str, **kwargs) -> Dict[str, Any]:
75
+ """
76
+ Sends a prompt to KubeMind Router's intent routing proxy directly.
77
+ """
78
+ url = f"{self.router_url}/v1/route"
79
+ payload = {
80
+ "prompt": prompt,
81
+ **kwargs
82
+ }
83
+ with httpx.Client(timeout=self.timeout) as client:
84
+ resp = client.post(url, headers=self.headers, json=payload)
85
+ resp.raise_for_status()
86
+ return resp.json()
87
+
88
+ def classify(self, prompt: str) -> Dict[str, Any]:
89
+ """
90
+ Dry-run classify the prompt intent and sensitivity.
91
+ """
92
+ url = f"{self.router_url}/v1/classify"
93
+ payload = {
94
+ "prompt": prompt
95
+ }
96
+ with httpx.Client(timeout=self.timeout) as client:
97
+ resp = client.post(url, headers=self.headers, json=payload)
98
+ resp.raise_for_status()
99
+ return resp.json()
100
+
101
+ def ingest_memory(self, content: str, source: str = "sdk", metadata: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
102
+ """
103
+ Ingest documents/knowledge into the KubeMind knowledge graph (Mind).
104
+ """
105
+ url = f"{self.mind_url}/v1/ingest"
106
+ payload = {
107
+ "content": content,
108
+ "source": source,
109
+ "metadata": metadata or {}
110
+ }
111
+ with httpx.Client(timeout=self.timeout) as client:
112
+ resp = client.post(url, headers=self.headers, json=payload)
113
+ resp.raise_for_status()
114
+ return resp.json()
115
+
116
+ def query_memory(self, query: str, filters: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
117
+ """
118
+ Query the memory knowledge graph.
119
+ """
120
+ url = f"{self.mind_url}/v1/query"
121
+ payload = {
122
+ "query": query,
123
+ "filters": filters or {}
124
+ }
125
+ with httpx.Client(timeout=self.timeout) as client:
126
+ resp = client.post(url, headers=self.headers, json=payload)
127
+ resp.raise_for_status()
128
+ return resp.json()
129
+
130
+ def verify_audit_ledger(self, limit: int = 50) -> Dict[str, Any]:
131
+ """
132
+ Verify and fetch the audit ledger entries from Sentinel.
133
+ """
134
+ url = f"{self.sentinel_url}/v1/audit/verify"
135
+ params = {
136
+ "workspace_id": self.workspace_id,
137
+ "limit": limit
138
+ }
139
+ with httpx.Client(timeout=self.timeout) as client:
140
+ resp = client.get(url, headers=self.headers, params=params)
141
+ resp.raise_for_status()
142
+ return resp.json()
143
+
144
+ def get_cost_analytics(self, window_hours: int = 24) -> Dict[str, Any]:
145
+ """
146
+ Fetch aggregated cost, token, and provider usage analytics.
147
+ """
148
+ url = f"{self.router_url}/v1/usage/analytics"
149
+ params = {
150
+ "window_hours": window_hours
151
+ }
152
+ with httpx.Client(timeout=self.timeout) as client:
153
+ resp = client.get(url, headers=self.headers, params=params)
154
+ resp.raise_for_status()
155
+ return resp.json()
156
+
157
+ def get_org_analytics(self, window_hours: int = 720) -> Dict[str, Any]:
158
+ """
159
+ Fetch cross-workspace org-wide financial and token rollups.
160
+ """
161
+ url = f"{self.router_url}/v1/usage/org-analytics"
162
+ params = {
163
+ "window_hours": window_hours
164
+ }
165
+ with httpx.Client(timeout=self.timeout) as client:
166
+ resp = client.get(url, headers=self.headers, params=params)
167
+ resp.raise_for_status()
168
+ return resp.json()
169
+
@@ -0,0 +1,83 @@
1
+ Metadata-Version: 2.4
2
+ Name: kubemind
3
+ Version: 0.1.0
4
+ Summary: Official Python client SDK for KubeMind AI Gateway and Governance Control Plane
5
+ Author: KubeMind team
6
+ Author-email: KubeMind Team <maintainers@kubemind.io>
7
+ License: MIT
8
+ Project-URL: Homepage, https://kubemind.io
9
+ Project-URL: Documentation, https://kubemind.io/docs
10
+ Project-URL: Repository, https://github.com/kubemind/kubemind
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Security
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ Requires-Dist: httpx>=0.23.0
25
+ Dynamic: author
26
+ Dynamic: requires-python
27
+
28
+ # KubeMind Python SDK (`kubemind`)
29
+
30
+ The official Python client library for **KubeMind** — the self-hosted intelligent AI gateway and governance control plane.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install kubemind
36
+ ```
37
+
38
+ ## Quickstart
39
+
40
+ ```python
41
+ from kubemind import KubeMindClient
42
+
43
+ # Initialize client with API key and workspace ID
44
+ client = KubeMindClient(
45
+ api_key="your-api-key",
46
+ workspace_id="default",
47
+ router_url="http://localhost:9080",
48
+ mind_url="http://localhost:9081",
49
+ sentinel_url="http://localhost:9083",
50
+ )
51
+
52
+ # 1. Chat completion with intent classification & sensitivity governance
53
+ completion = client.chat_completion(
54
+ model="llama3.1",
55
+ messages=[
56
+ {"role": "user", "content": "Email alice@example.com the summary report"}
57
+ ]
58
+ )
59
+ print("Response:", completion["choices"][0]["message"]["content"])
60
+ print("Routing Decision:", completion.get("routing_decision"))
61
+
62
+ # 2. Semantic prompt routing
63
+ route = client.route("What is our company expense policy?")
64
+ print("Content:", route.get("content"))
65
+ print("Retrieval Status:", route.get("retrieval_status"))
66
+
67
+ # 3. CFO Cost & Usage Analytics
68
+ analytics = client.get_cost_analytics(window_hours=24)
69
+ print(f"Total Requests: {analytics['total_requests']}")
70
+ print(f"Estimated Spend ($): {analytics['estimated_spend_usd']}")
71
+
72
+ # 4. Cryptographic Ledger Verification
73
+ audit = client.verify_audit_ledger()
74
+ print("Ledger Intact:", audit.get("verified"))
75
+ ```
76
+
77
+ ## Features
78
+
79
+ - **Pre-Dispatch Sensitivity Gating**: Inline regex + local offline NER tokenization with in-memory reversible restoration.
80
+ - **Intent-Driven Routing**: Routes prompts dynamically based on classified semantic intent.
81
+ - **Fail-Closed Grounding**: Distinguishes verified corporate knowledge from hallucinations.
82
+ - **SHA-256 Tamper-Evident Ledger**: Verifiable cryptographic audit trail for HIPAA/SOC2 compliance.
83
+ - **Granular RBAC**: Supports role-scoped API keys (`admin`, `developer`, `auditor`, `viewer`).
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ kubemind/__init__.py
5
+ kubemind/client.py
6
+ kubemind.egg-info/PKG-INFO
7
+ kubemind.egg-info/SOURCES.txt
8
+ kubemind.egg-info/dependency_links.txt
9
+ kubemind.egg-info/requires.txt
10
+ kubemind.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ httpx>=0.23.0
@@ -0,0 +1 @@
1
+ kubemind
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "kubemind"
7
+ version = "0.1.0"
8
+ description = "Official Python client SDK for KubeMind AI Gateway and Governance Control Plane"
9
+ readme = "README.md"
10
+ authors = [{ name = "KubeMind Team", email = "maintainers@kubemind.io" }]
11
+ license = { text = "MIT" }
12
+ requires-python = ">=3.8"
13
+ dependencies = [
14
+ "httpx>=0.23.0",
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.8",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
27
+ "Topic :: Security",
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = "https://kubemind.io"
32
+ Documentation = "https://kubemind.io/docs"
33
+ Repository = "https://github.com/kubemind/kubemind"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,13 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="kubemind",
5
+ version="0.1.0",
6
+ packages=find_packages(),
7
+ install_requires=[
8
+ "httpx>=0.20.0",
9
+ ],
10
+ author="KubeMind team",
11
+ description="Official Python SDK for the KubeMind gateway and governance plane",
12
+ python_requires=">=3.8",
13
+ )