Skip to main content

brussle (Python)

Brussle is a database where a column, a judgment, can be an AI model's answer about a document. The answer can read other documents. For example, Which open invoice does this payment settle? reads the payment beside its customer's open invoices. When an invoice changes, Brussle judges the payments that read it again. Each answer says whether it is current, and records the judgment version and engine version behind it. You can measure each answer against the outcomes that you record. If an answer reads only its own document, a column in your own database may be enough.

This package is the Python client for the Brussle API.

import os
from brussle import Client

db = Client(api_key=os.environ["BRUSSLE_API_KEY"])
ns = db.namespace("acme/prod/tenant_123")

# A judgment on unmatched payments that reads the open invoices in the same block.
ns.judgments.create(
    from_starter="payments.settles",
    paths={
        "kind": "attributes.kind",
        "payment_kind": "payment",
        "invoice_kind": "invoice",
        "status": "attributes.status",
        "unmatched": "unmatched",
        "open": "open",
        "block": "attributes.block",
        "payment_amount": "state.amount",
        "reference": "state.reference",
        "invoice_number": "state.number",
        "invoice_amount": "state.amount",
    },
    engine={"name": "jev", "version": "current"},
    freshness={"policy": "on_change"},
    confirm=True,
)

# An open invoice, and a payment in the same block.
ns.write(upsert=[
    {"id": "inv_1002", "attributes": {"kind": "invoice", "status": "open", "block": "northwind-gbp"}, "state": {"number": "INV-1002", "amount": 1200}},
    {"id": "pay_1", "attributes": {"kind": "payment", "status": "unmatched", "block": "northwind-gbp"}, "state": {"amount": 1200, "reference": "Northwind INV-1002"}},
])

# A change to the block's open invoices judges its payments again. Query the payments that wait for a person,
# with a current answer only.
page = ns.query(
    filters=("answers.settles.thresholds.unmatched", "Eq", True),
    answers="fresh_only",
    include={"answers": ["settles"]},
)

The quickstart runs this example step by step. Relations lists what else a judgment can read.

To load many documents, import_documents takes any iterable and writes it in batches, 4 at a time on a thread pool, with retries:

summary = ns.import_documents(records(), concurrency=4)
print(summary.documents, summary.failures)

How the client works:

  • Methods mirror the API's routes.
  • Every route that changes something takes idempotency_key=. A call that would not be safe to repeat without one, such as a create, gets a key the SDK generates when you pass none, the same on each retry of that call.
  • Calls are retried after network errors, timeouts, 502, 503 and 504, and after a 429 or 503 with Retry-After, 2 times by default (max_retries). A 500 is retried only for reads, writes and the other calls that are safe to repeat without a key.
  • ns.judgments.create, update and backfill can take more than 20 s. The API then answers with a job, and the call waits for it: it checks the job every 1 to 10 s, or after the API's Retry-After, for up to wait_timeout seconds (10 minutes by default). It then returns or raises what the call would have. After the timeout it raises JobWaitTimeoutError, whose job["id"] you can pass to db.jobs.wait. With wait=False the call returns {"accepted": False, "result": ...} or {"accepted": True, "job": ...}.
  • Requests and responses are plain JSON, typed in brussle.types. One exception: ns.outcomes.append takes the list of outcomes, not the whole request body.
  • Filters and rank_by are tuples.
  • Errors raise ApiError with the API's code and details. The code is unknown for an error response that is not the API's JSON for example a proxy's error page, and for a success whose body is not JSON.
  • A call that your organization's plan does not include raises plan_required (402). details["required_plan"] names the plan that includes it.

See the SDK reference.

Metadata

Release files for brussle 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for brussle 1.3.0
File Size Uploaded Provenance Actions
brussle-1.3.0.tar.gz 134.1 kB Without provenance Details for brussle-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for brussle 1.3.0
File Interpreter ABI Platform Actions
brussle-1.3.0-py3-none-any.whl Python 3 none any Details for brussle-1.3.0-py3-none-any.whl

Total release size: 217.1 kB

Release files / brussle-1.3.0.tar.gz

Download URL brussle-1.3.0.tar.gz
Size 134.1 kB
Tags Source
SHA-256 checksum
How to use checksums
30badf4577ea3407151b36db98fa356d9055a5b02859897dd2278b6a41ee7716
BLAKE2b-256 checksum
How to use checksums
f647860a4e57bad9357d253d63fe4adbcd787f3aac2ca3040da07c0744110a65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / brussle-1.3.0-py3-none-any.whl

Download URL brussle-1.3.0-py3-none-any.whl
Size 83.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73126669c87d7ef74c4b4f9b70b604bd5ab2c59ee397d9ddebec85eab9d8db7a
BLAKE2b-256 checksum
How to use checksums
37b943a7f05f18c4f45643721ff7a5d1822a4c3cc2bff809c9a0e138e31de98c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for brussle 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page