hebbrix 2.1.1__tar.gz → 2.3.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.
hebbrix-2.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Hebbrix
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.
@@ -1,5 +1,4 @@
1
1
  include README.md
2
2
  include LICENSE
3
3
  include pyproject.toml
4
- recursive-include hebbrix_sdk *.py
5
-
4
+ recursive-include hebbrix *.py
@@ -1,12 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hebbrix
3
- Version: 2.1.1
3
+ Version: 2.3.0
4
4
  Summary: Advanced Memory API for AI Agents with Reinforcement Learning - 3-line integration
5
- Home-page: https://github.com/hebbrix/hebbrix-python
6
- Author: Hebbrix Team
7
5
  Author-email: Hebbrix Team <support@hebbrix.com>
8
6
  Maintainer-email: Hebbrix Team <support@hebbrix.com>
9
- License: MIT
7
+ License-Expression: MIT
10
8
  Project-URL: Homepage, https://hebbrix.com
11
9
  Project-URL: Documentation, https://docs.hebbrix.com
12
10
  Project-URL: Repository, https://github.com/hebbrix/hebbrix-python
@@ -18,7 +16,6 @@ Classifier: Intended Audience :: Developers
18
16
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
17
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
18
  Classifier: Topic :: Database
21
- Classifier: License :: OSI Approved :: MIT License
22
19
  Classifier: Programming Language :: Python :: 3
23
20
  Classifier: Programming Language :: Python :: 3.8
24
21
  Classifier: Programming Language :: Python :: 3.9
@@ -29,17 +26,18 @@ Classifier: Operating System :: OS Independent
29
26
  Classifier: Framework :: AsyncIO
30
27
  Requires-Python: >=3.8
31
28
  Description-Content-Type: text/markdown
29
+ License-File: LICENSE
32
30
  Requires-Dist: httpx>=0.25.0
33
31
  Requires-Dist: requests>=2.31.0
34
32
  Provides-Extra: dev
35
33
  Requires-Dist: pytest>=7.0.0; extra == "dev"
36
34
  Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
37
35
  Requires-Dist: black>=23.0.0; extra == "dev"
38
- Requires-Dist: flake8>=6.0.0; extra == "dev"
36
+ Requires-Dist: flake8<6.0.0,>=5.0.4; python_full_version < "3.8.1" and extra == "dev"
37
+ Requires-Dist: flake8>=6.0.0; python_full_version >= "3.8.1" and extra == "dev"
39
38
  Requires-Dist: mypy>=1.0.0; extra == "dev"
40
- Dynamic: author
41
- Dynamic: home-page
42
- Dynamic: requires-python
39
+ Requires-Dist: cryptography>=42.0.0; extra == "dev"
40
+ Dynamic: license-file
43
41
 
44
42
  # Hebbrix Python SDK
45
43
 
@@ -51,13 +49,14 @@ Official Python SDK for the Hebbrix api - **the only memory API with Reinforceme
51
49
 
52
50
  ## 🚀 Features
53
51
 
54
- - ✅ **Complete API Coverage** - All 50+ endpoints supported
52
+ - ✅ **Core API Coverage** - Typed resources for memories, search, and ProofLoop
55
53
  - ✅ **Reinforcement Learning** - Train AI agents to optimize memory operations
56
54
  - ✅ **Temporal Knowledge Graphs** - Track facts over time with bi-temporal model
57
55
  - ✅ **Procedural Memory** - Store and execute learned skills
58
56
  - ✅ **Working Memory** - Short-term context buffer for conversations
59
57
  - ✅ **Memory Consolidation** - Automatic compression of episodic memories
60
- - ✅ **Async/Await** - Full async support with httpx
58
+ - ✅ **ProofLoop** - Learn from outcomes with automatic, verifiable evidence receipts
59
+ - ✅ **Sync + Async** - Equivalent core memory and ProofLoop workflows
61
60
  - ✅ **Type Hints** - Complete type annotations
62
61
  - ✅ **Clean API** - Pythonic, intuitive interface
63
62
 
@@ -86,8 +85,11 @@ async def main():
86
85
  # Store a memory
87
86
  memory = await client.memories.create(
88
87
  collection_id=collection["id"],
88
+ user_id="customer-7",
89
+ agent_id="support-agent",
89
90
  content="User prefers dark mode and loves Python",
90
- importance=0.9
91
+ importance=0.9,
92
+ wait_for_index=True,
91
93
  )
92
94
 
93
95
  # Search memories
@@ -105,6 +107,47 @@ async def main():
105
107
  asyncio.run(main())
106
108
  ```
107
109
 
110
+ Blocking applications can use the same create/search/ProofLoop fields:
111
+
112
+ ```python
113
+ from hebbrix import SyncMemoryClient
114
+
115
+ with SyncMemoryClient(api_key="mem_sk_your_api_key") as client:
116
+ collection = client.collections.create(name="My Agent")
117
+ client.memories.create(
118
+ collection_id=collection["id"],
119
+ user_id="customer-7",
120
+ content="User prefers concise answers",
121
+ wait_for_index=True,
122
+ )
123
+ results = client.search(
124
+ "How should answers be formatted?",
125
+ collection_id=collection["id"],
126
+ user_id="customer-7",
127
+ )
128
+ ```
129
+
130
+ ## ProofLoop: search → decision → outcome → proof
131
+
132
+ ```python
133
+ search = await client.search_with_proof(
134
+ "What should the agent do next?",
135
+ collection_id="collection-42",
136
+ user_id="customer-7",
137
+ )
138
+ decision = await client.proofloop.decide(
139
+ policy_key="agent.next_action",
140
+ candidates=[{"action_key": "act"}, {"action_key": "ask"}],
141
+ collection_id="collection-42",
142
+ user_id="customer-7",
143
+ proof_context=search["proof_context"],
144
+ )
145
+ await client.proofloop.record_outcome(
146
+ decision["decision_id"], success=True, idempotency_key="run-123-result"
147
+ )
148
+ proof = await client.proofloop.proof(decision["decision_id"])
149
+ ```
150
+
108
151
  ## 📚 Complete Documentation
109
152
 
110
153
  Visit https://docs.hebbrix.com for full documentation.
@@ -8,13 +8,14 @@ Official Python SDK for the Hebbrix api - **the only memory API with Reinforceme
8
8
 
9
9
  ## 🚀 Features
10
10
 
11
- - ✅ **Complete API Coverage** - All 50+ endpoints supported
11
+ - ✅ **Core API Coverage** - Typed resources for memories, search, and ProofLoop
12
12
  - ✅ **Reinforcement Learning** - Train AI agents to optimize memory operations
13
13
  - ✅ **Temporal Knowledge Graphs** - Track facts over time with bi-temporal model
14
14
  - ✅ **Procedural Memory** - Store and execute learned skills
15
15
  - ✅ **Working Memory** - Short-term context buffer for conversations
16
16
  - ✅ **Memory Consolidation** - Automatic compression of episodic memories
17
- - ✅ **Async/Await** - Full async support with httpx
17
+ - ✅ **ProofLoop** - Learn from outcomes with automatic, verifiable evidence receipts
18
+ - ✅ **Sync + Async** - Equivalent core memory and ProofLoop workflows
18
19
  - ✅ **Type Hints** - Complete type annotations
19
20
  - ✅ **Clean API** - Pythonic, intuitive interface
20
21
 
@@ -43,8 +44,11 @@ async def main():
43
44
  # Store a memory
44
45
  memory = await client.memories.create(
45
46
  collection_id=collection["id"],
47
+ user_id="customer-7",
48
+ agent_id="support-agent",
46
49
  content="User prefers dark mode and loves Python",
47
- importance=0.9
50
+ importance=0.9,
51
+ wait_for_index=True,
48
52
  )
49
53
 
50
54
  # Search memories
@@ -62,6 +66,47 @@ async def main():
62
66
  asyncio.run(main())
63
67
  ```
64
68
 
69
+ Blocking applications can use the same create/search/ProofLoop fields:
70
+
71
+ ```python
72
+ from hebbrix import SyncMemoryClient
73
+
74
+ with SyncMemoryClient(api_key="mem_sk_your_api_key") as client:
75
+ collection = client.collections.create(name="My Agent")
76
+ client.memories.create(
77
+ collection_id=collection["id"],
78
+ user_id="customer-7",
79
+ content="User prefers concise answers",
80
+ wait_for_index=True,
81
+ )
82
+ results = client.search(
83
+ "How should answers be formatted?",
84
+ collection_id=collection["id"],
85
+ user_id="customer-7",
86
+ )
87
+ ```
88
+
89
+ ## ProofLoop: search → decision → outcome → proof
90
+
91
+ ```python
92
+ search = await client.search_with_proof(
93
+ "What should the agent do next?",
94
+ collection_id="collection-42",
95
+ user_id="customer-7",
96
+ )
97
+ decision = await client.proofloop.decide(
98
+ policy_key="agent.next_action",
99
+ candidates=[{"action_key": "act"}, {"action_key": "ask"}],
100
+ collection_id="collection-42",
101
+ user_id="customer-7",
102
+ proof_context=search["proof_context"],
103
+ )
104
+ await client.proofloop.record_outcome(
105
+ decision["decision_id"], success=True, idempotency_key="run-123-result"
106
+ )
107
+ proof = await client.proofloop.proof(decision["decision_id"])
108
+ ```
109
+
65
110
  ## 📚 Complete Documentation
66
111
 
67
112
  Visit https://docs.hebbrix.com for full documentation.
@@ -41,24 +41,26 @@ Features:
41
41
  - ✅ Type hints throughout
42
42
  """
43
43
 
44
- __version__ = "2.1.1"
44
+ __version__ = "2.3.0"
45
45
  __author__ = "Hebbrix Team"
46
46
  __license__ = "MIT"
47
47
 
48
- from hebbrix.client import MemoryClient
49
48
  from hebbrix.chat import MemoryChat
49
+ from hebbrix.client import MemoryClient
50
50
  from hebbrix.exceptions import (
51
- HebbrixError,
52
51
  AuthenticationError,
53
- ValidationError,
52
+ HebbrixError,
54
53
  NotFoundError,
55
54
  RateLimitError,
56
55
  ServerError,
56
+ ValidationError,
57
57
  )
58
-
58
+ from hebbrix.models import EvidenceClaim, GroundingReceipt, SearchSafetyEnvelope
59
+ from hebbrix.sync_client import SyncMemoryClient
59
60
 
60
61
  __all__ = [
61
62
  "MemoryClient",
63
+ "SyncMemoryClient",
62
64
  "MemoryChat",
63
65
  "HebbrixError",
64
66
  "AuthenticationError",
@@ -66,4 +68,7 @@ __all__ = [
66
68
  "NotFoundError",
67
69
  "RateLimitError",
68
70
  "ServerError",
71
+ "GroundingReceipt",
72
+ "EvidenceClaim",
73
+ "SearchSafetyEnvelope",
69
74
  ]
@@ -8,14 +8,30 @@ import os
8
8
  from typing import Any, Dict, List, Optional
9
9
 
10
10
  import httpx
11
- from hebbrix.exceptions import (AuthenticationError, HebbrixError,
12
- NotFoundError, RateLimitError, ServerError,
13
- ValidationError)
14
- from hebbrix.resources import (AuthResource, CollectionsResource,
15
- ConsolidationResource, MemoriesResource,
16
- MemoryToolsResource, ProceduralResource,
17
- RLResource, SearchResource, TemporalResource,
18
- WorkingMemoryResource, WorldModelResource)
11
+ from hebbrix.exceptions import (
12
+ AuthenticationError,
13
+ HebbrixError,
14
+ NotFoundError,
15
+ RateLimitError,
16
+ ServerError,
17
+ ValidationError,
18
+ )
19
+ from hebbrix.resources import (
20
+ AuthResource,
21
+ CollectionsResource,
22
+ ConsolidationResource,
23
+ CorrectionsResource,
24
+ MemoriesResource,
25
+ MemoryJobsResource,
26
+ MemoryToolsResource,
27
+ ProceduralResource,
28
+ ProofLoopResource,
29
+ RLResource,
30
+ SearchResource,
31
+ TemporalResource,
32
+ WorkingMemoryResource,
33
+ WorldModelResource,
34
+ )
19
35
 
20
36
 
21
37
  class MemoryClient:
@@ -59,7 +75,10 @@ class MemoryClient:
59
75
  self.auth = AuthResource(self)
60
76
  self.collections = CollectionsResource(self)
61
77
  self.memories = MemoriesResource(self)
78
+ self.memory_jobs = MemoryJobsResource(self)
79
+ self.corrections = CorrectionsResource(self)
62
80
  self.search_resource = SearchResource(self)
81
+ self.proofloop = ProofLoopResource(self)
63
82
  self.rl = RLResource(self)
64
83
  self.procedural = ProceduralResource(self)
65
84
  self.temporal = TemporalResource(self)
@@ -72,7 +91,7 @@ class MemoryClient:
72
91
  """Get request headers."""
73
92
  headers = {
74
93
  "Content-Type": "application/json",
75
- "User-Agent": "hebbrix-python/2.0.0",
94
+ "User-Agent": "hebbrix-python/2.3.0",
76
95
  }
77
96
 
78
97
  if self.api_key:
@@ -160,6 +179,14 @@ class MemoryClient:
160
179
  limit: int = 10,
161
180
  search_type: str = "hybrid",
162
181
  filters: Optional[Dict[str, Any]] = None,
182
+ user_id: Optional[str] = None,
183
+ agent_id: Optional[str] = None,
184
+ run_id: Optional[str] = None,
185
+ fast: Optional[bool] = None,
186
+ threshold: Optional[float] = None,
187
+ include_low_confidence: bool = False,
188
+ group_by_source: bool = True,
189
+ debug: bool = False,
163
190
  ) -> List[Dict[str, Any]]:
164
191
  """
165
192
  Search memories.
@@ -180,6 +207,48 @@ class MemoryClient:
180
207
  limit=limit,
181
208
  search_type=search_type,
182
209
  filters=filters or {},
210
+ user_id=user_id,
211
+ agent_id=agent_id,
212
+ run_id=run_id,
213
+ fast=fast,
214
+ threshold=threshold,
215
+ include_low_confidence=include_low_confidence,
216
+ group_by_source=group_by_source,
217
+ debug=debug,
218
+ )
219
+
220
+ async def search_with_proof(
221
+ self,
222
+ query: str,
223
+ collection_id: Optional[str] = None,
224
+ limit: int = 10,
225
+ search_type: str = "hybrid",
226
+ filters: Optional[Dict[str, Any]] = None,
227
+ user_id: Optional[str] = None,
228
+ agent_id: Optional[str] = None,
229
+ run_id: Optional[str] = None,
230
+ fast: Optional[bool] = None,
231
+ threshold: Optional[float] = None,
232
+ include_low_confidence: bool = False,
233
+ group_by_source: bool = True,
234
+ debug: bool = False,
235
+ ) -> Dict[str, Any]:
236
+ """Search and return both results and the automatic ProofLoop context."""
237
+
238
+ return await self.search_resource.search_with_proof(
239
+ query=query,
240
+ collection_id=collection_id,
241
+ limit=limit,
242
+ search_type=search_type,
243
+ filters=filters or {},
244
+ user_id=user_id,
245
+ agent_id=agent_id,
246
+ run_id=run_id,
247
+ fast=fast,
248
+ threshold=threshold,
249
+ include_low_confidence=include_low_confidence,
250
+ group_by_source=group_by_source,
251
+ debug=debug,
183
252
  )
184
253
 
185
254
  async def reason(
@@ -188,6 +257,10 @@ class MemoryClient:
188
257
  collection_id: Optional[str] = None,
189
258
  provider: Optional[str] = None,
190
259
  include_steps: bool = False,
260
+ user_id: Optional[str] = None,
261
+ agent_id: Optional[str] = None,
262
+ run_id: Optional[str] = None,
263
+ facets: Optional[List[str]] = None,
191
264
  ) -> Dict[str, Any]:
192
265
  """
193
266
  Perform reasoning over memories.
@@ -197,6 +270,10 @@ class MemoryClient:
197
270
  collection_id: Optional collection filter
198
271
  provider: LLM provider (gemini, openai, anthropic)
199
272
  include_steps: Include reasoning steps
273
+ user_id: End-user isolation scope
274
+ agent_id: Agent isolation scope
275
+ run_id: Run isolation scope
276
+ facets: Optional typed decomposition facets
200
277
 
201
278
  Returns:
202
279
  Reasoning result with answer and sources
@@ -206,6 +283,10 @@ class MemoryClient:
206
283
  collection_id=collection_id,
207
284
  provider=provider,
208
285
  include_steps=include_steps,
286
+ user_id=user_id,
287
+ agent_id=agent_id,
288
+ run_id=run_id,
289
+ facets=facets,
209
290
  )
210
291
 
211
292
  async def close(self):
@@ -0,0 +1,40 @@
1
+ """Public response contracts for evidence-bearing Hebbrix operations."""
2
+
3
+ from typing import Any, Dict, List, TypedDict
4
+
5
+
6
+ class GroundingReceipt(TypedDict, total=False):
7
+ """Authoritative claim-grounding decision returned by the API."""
8
+
9
+ status: str
10
+ reason: str
11
+ contract_version: str
12
+ requested_predicate: str
13
+ requested_attribute: str
14
+ subject_anchors: List[str]
15
+
16
+
17
+ class EvidenceClaim(TypedDict, total=False):
18
+ """Claims attributed to one exact memory evidence identifier."""
19
+
20
+ memory_id: str
21
+ claims: Dict[str, Any]
22
+
23
+
24
+ class SearchSafetyEnvelope(TypedDict, total=False):
25
+ """Fail-closed response shared by search and reasoning helpers."""
26
+
27
+ query: str
28
+ results: List[Dict[str, Any]]
29
+ sources: List[Dict[str, Any]]
30
+ total: int
31
+ no_match: bool
32
+ abstain_recommended: bool
33
+ query_confidence: float
34
+ grounding: GroundingReceipt
35
+ evidence_ids: List[str]
36
+ evidence_claims: List[EvidenceClaim]
37
+ safety_contract_version: str
38
+ degraded: bool
39
+ sdk_safety_reason: str
40
+ proof_context: Dict[str, Any]