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 @usekaval/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.1.tar.gz (10.2 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.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kaval-0.1.1.tar.gz
  • Upload date:
  • Size: 10.2 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.1.tar.gz
Algorithm Hash digest
SHA256 065b3d6b16b91c0985b35b8049aaefc75cd4722243774f67e294ada28d7e4dfe
MD5 ae38246f3fb815dafb532122a8c9abea
BLAKE2b-256 0783f8b307af0ef2d544df3ebd8eab94cbbab528b6a5c8808fe97e7fdf7d2114

See more details on using hashes here.

Provenance

The following attestation bundles were made for kaval-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: kaval-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 79ceeed655f9d5b763b620edcdfbdc6f9722e5896d62e80b881f730caf8046e3
MD5 45fd95fcf7a2d04a3b3185fa45d65ef3
BLAKE2b-256 37458be66a704bd0e64884dc21603e80acc8586ac157afac73e30a20e903f8da

See more details on using hashes here.

Provenance

The following attestation bundles were made for kaval-0.1.1-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