Beta CortexDB HTTP client
Project description
cortexdb-sdk
Stdlib Python client for the Core Alpha CortexDB HTTP API.
from cortexdb_client import ContextPackResponse, CortexDBClient
client = CortexDBClient("http://127.0.0.1:8181").with_retries(3, retry_delay_seconds=0.1).with_timeout(5.0)
with client.with_session() as session:
tenant_client = session.with_tenant("tenant:alpha")
session.put_cell(1, "scope=default\nstatus=ready\nhello")
print(session.get_cell(1))
print(tenant_client.stats())
results = session.search_response("default", "hello")
print(results.search_mode, results.ann_report, results.results)
ann_eval = session.evaluate_ann_response("default", [1, 2, 3])
print(ann_eval.available, ann_eval.recall_q16)
retrieve = session.build_retrieve_context_aql("hello", "default", limit_candidates=10)
context: ContextPackResponse = session.context_response("default", retrieve)
verify = session.verify_response("default", session.build_verify_fact_aql("hello", "default"))
remember = session.remember_response("default", session.build_remember_aql("hello", "default", "decision", ttl_seconds=3600))
print(context.token_budget_tokens, verify.status, remember.cell_id)
print(session.ingest_text("default", "hello from sdk"))
grounded = client.answer_with_grounded_context(
"default",
"default",
"What does the context say about hello?",
lambda pack: pack.cells[0].payload_text if pack.cells else "Not enough information.",
mode="audit",
limit_candidates=10,
)
print(grounded.citations, grounded.grounding.answer_supported)
The package metadata is prepared for PyPI as cortexdb-sdk. Publication is
not automatic; run ../publish/check.sh before cutting a package release.
Run make sdk-contract-check from the repository root to validate this client
against a freshly built local cortex-server together with the TypeScript and
Rust SDKs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cortexdb_sdk-0.2.0b2.tar.gz.
File metadata
- Download URL: cortexdb_sdk-0.2.0b2.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a9a7277d48bbf6f0fd5d80721586684b56788d1a22a73ef285800ff67c887ca
|
|
| MD5 |
8edd3b6a41e043459e002326c12187b6
|
|
| BLAKE2b-256 |
37bca9350a1d6cfdfc86255c31588031b45ac2ec873f87e92f1161535b4ff063
|
File details
Details for the file cortexdb_sdk-0.2.0b2-py3-none-any.whl.
File metadata
- Download URL: cortexdb_sdk-0.2.0b2-py3-none-any.whl
- Upload date:
- Size: 25.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d232e8186df1c1a5cf8e92a0050dbd9b11674e2f2a93693887c73ac35422360
|
|
| MD5 |
e21a1d1ac2e3454fc996d53b93bb1c35
|
|
| BLAKE2b-256 |
80ea5de2b8a9c9e30ca6a4df31ebc4c60c3b6ea167d910573ed2704595834af1
|