cortexdbai 0.3.1__tar.gz → 0.3.2__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.
- {cortexdbai-0.3.1 → cortexdbai-0.3.2}/PKG-INFO +1 -1
- {cortexdbai-0.3.1 → cortexdbai-0.3.2}/cortexdb/__init__.py +1 -1
- {cortexdbai-0.3.1 → cortexdbai-0.3.2}/cortexdb/v1/client.py +29 -3
- {cortexdbai-0.3.1 → cortexdbai-0.3.2}/pyproject.toml +1 -1
- {cortexdbai-0.3.1 → cortexdbai-0.3.2}/.gitignore +0 -0
- {cortexdbai-0.3.1 → cortexdbai-0.3.2}/README.md +0 -0
- {cortexdbai-0.3.1 → cortexdbai-0.3.2}/cortexdb/py.typed +0 -0
- {cortexdbai-0.3.1 → cortexdbai-0.3.2}/cortexdb/v1/__init__.py +0 -0
- {cortexdbai-0.3.1 → cortexdbai-0.3.2}/cortexdb/v1/exceptions.py +0 -0
- {cortexdbai-0.3.1 → cortexdbai-0.3.2}/tests/__init__.py +0 -0
|
@@ -62,6 +62,22 @@ def _build_headers(
|
|
|
62
62
|
return h
|
|
63
63
|
|
|
64
64
|
|
|
65
|
+
def _capture_sdk_error(exc: BaseException) -> None:
|
|
66
|
+
"""Best-effort client-side error tracking (observability plan, Phase 6).
|
|
67
|
+
|
|
68
|
+
If the host application uses Sentry, forward SDK transport/API errors to
|
|
69
|
+
it so failures users hit are visible to the operator. This is a NO-OP when
|
|
70
|
+
``sentry_sdk`` isn't installed or isn't initialized — the SDK never
|
|
71
|
+
initializes Sentry itself (the app owns that decision and the DSN)."""
|
|
72
|
+
try:
|
|
73
|
+
import sentry_sdk
|
|
74
|
+
|
|
75
|
+
if sentry_sdk.Hub.current.client is not None:
|
|
76
|
+
sentry_sdk.capture_exception(exc)
|
|
77
|
+
except Exception:
|
|
78
|
+
pass
|
|
79
|
+
|
|
80
|
+
|
|
65
81
|
def _raise_for_response(status: int, text: str) -> None:
|
|
66
82
|
"""If the response is non-2xx, raise the most-specific V1APIError
|
|
67
83
|
subclass derived from the v1 error envelope. Otherwise return None."""
|
|
@@ -71,7 +87,9 @@ def _raise_for_response(status: int, text: str) -> None:
|
|
|
71
87
|
body = json.loads(text) if text else {}
|
|
72
88
|
except json.JSONDecodeError:
|
|
73
89
|
body = {"error_code": "UNKNOWN", "message": text[:500]}
|
|
74
|
-
|
|
90
|
+
err = V1APIError.from_response(status, body)
|
|
91
|
+
_capture_sdk_error(err)
|
|
92
|
+
raise err
|
|
75
93
|
|
|
76
94
|
|
|
77
95
|
def _envelope(
|
|
@@ -260,11 +278,18 @@ class V1Client:
|
|
|
260
278
|
self,
|
|
261
279
|
scope: str,
|
|
262
280
|
items: Iterable[Mapping[str, Any]],
|
|
281
|
+
*,
|
|
282
|
+
wait: Optional[str] = None,
|
|
263
283
|
) -> dict:
|
|
264
284
|
"""``POST /v1/experience/bulk`` — accepts up to 1000 envelopes per
|
|
265
285
|
request. ``items`` is a sequence of dicts with at least ``text``
|
|
266
286
|
(or ``json_data``) plus optional ``role`` / ``observed_at`` /
|
|
267
|
-
``labels`` / ``idempotency_key`` keys.
|
|
287
|
+
``labels`` / ``idempotency_key`` keys.
|
|
288
|
+
|
|
289
|
+
``wait`` turns the batch into a barrier: pass ``"indexed"`` (or
|
|
290
|
+
``"consolidated"`` etc.) to block until every accepted event reaches
|
|
291
|
+
that stage before returning — the batch analogue of
|
|
292
|
+
:meth:`experience`'s ``wait``, ideal for bulk-ingest-then-recall."""
|
|
268
293
|
envelopes = [
|
|
269
294
|
_envelope(
|
|
270
295
|
scope=str(item.get("scope", scope)),
|
|
@@ -278,7 +303,8 @@ class V1Client:
|
|
|
278
303
|
)
|
|
279
304
|
for item in items
|
|
280
305
|
]
|
|
281
|
-
|
|
306
|
+
path = "/v1/experience/bulk" + (f"?wait={wait}" if wait else "")
|
|
307
|
+
return self._post(path, {"items": envelopes})
|
|
282
308
|
|
|
283
309
|
# ── recall + answer ───────────────────────────────────────────────
|
|
284
310
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|