Skip to main content

Python SDK for the kaval currentness API (belief in → typed freshness gap out).

Project description

kaval (Python SDK)

The freshness gate for AI. Give kaval a belief your system already holds — a cached fact, a CRM field, an agent memory — and it checks the live world and returns a typed freshness gap: current / stale / contradicted / unsupported / conflicting / insufficient.

Install

pip install kaval

Gate a belief before you act on it

from kaval import KavalClient

# base_url defaults to the hosted cloud (https://api.usekaval.com).
with KavalClient(api_key="kv_live_...") as client:
    decision = client.verify("Acme's CEO is Jane Doe")
    if not decision["act"]:
        ...  # stale / contradicted — re-fetch before relying on it

verify() returns the verdict plus actTrue only when the belief is current and confident (≥ 0.7 by default; override with min_confidence).

Pick a speed/depth tier

verify(belief, mode=...) selects a tier (default auto): instant (cache / graph-prior only, no fetch or LLM), fast (cheap model, origin-only), auto (balanced), or deep (strongest model + a cited explanation). The returned dict echoes tier, and on the deep tier adds explanation:

gap = client.verify("Acme's CEO is Jane Doe", mode="deep")
gap["tier"]                       # "deep"
gap["explanation"]["content"]     # markdown rationale with [n] citations (deep only)
gap["explanation"]["citations"]   # [{"url": ..., "title"?: ...}] — only from gathered evidence
gap["explanation"]["confidence"]  # "high" | "medium" | "low"

Sweep a store for drift

report = client.scan_store(["Acme is on the Enterprise plan", "Jane Doe is VP Eng at Acme"])
for r in report["riskiest"]:
    print(r["belief"], "→", r["status"])

# …or get pushed the newly-stale ones (carry `state` across runs so a still-stale belief
# isn't re-delivered every sweep):
client.monitor(beliefs, webhook="https://your-app.com/hooks/stale")

Custom base URL

Override the API base URL (e.g. a staging environment or a local proxy):

client = KavalClient(base_url="https://staging.api.usekaval.com", api_key="...")

API

verify · check · extract_and_check · scan_store · monitor · report_outcome · kaval · kaval_batch · health. Construct with KavalClient(base_url=?, api_key=?)base_url defaults to https://api.usekaval.com. The Node/TypeScript client mirrors this surface: npm install kaval.

Test

pip install -e ".[dev]"            # from sdks/python (development)
pytest                             # hermetic contract tests (httpx MockTransport)
KAVAL_BASE_URL=https://api.usekaval.com KAVAL_API_KEY=kv_live_... pytest   # also runs the live test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kaval-0.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kaval-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file kaval-0.1.0.tar.gz.

File metadata

  • Download URL: kaval-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kaval-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6ef001b2cf4ed6e816f9963be45d5ef835614e7c5082ddc08f96d37ab7b8c607
MD5 26e8859340cacb95ba1e17acb9d5b329
BLAKE2b-256 f43a3b9e70227e2802deaa773d5d28d5ca0a30204d22f9e2f6d6f83cd16e9ed1

See more details on using hashes here.

Provenance

The following attestation bundles were made for kaval-0.1.0.tar.gz:

Publisher: release.yml on LufeMC/kaval-clients

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kaval-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kaval-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kaval-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d0a2f48c9d4498c88bcf185ab0ccfbc01d268b57a0946b40391987fbe9a1cf2
MD5 481f5aaa52bd91b18eb36b9780f4c1ee
BLAKE2b-256 ad5bfc7358cfda683b8e4600bf6d9ab05acd4e07cea3104eae7860e10ecd1216

See more details on using hashes here.

Provenance

The following attestation bundles were made for kaval-0.1.0-py3-none-any.whl:

Publisher: release.yml on LufeMC/kaval-clients

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page