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.
The example uses Jev at current. A judgment can name any engine version that db.engines.list() (GET /engines) lists as active: today jev current and gpt-6-luna current. Both are unpinned, so each answer records the epoch of the model behind it. They differ in two ways that you choose by: only gpt-6-luna reads images, and each gpt-6-luna judgment counts 2.5 times on the bill. See engines. The API also names pplx-decider, which has no active version yet, so a judgment that names it is refused with engine_version_unavailable.
A document keeps its images in images, beside attributes and state. Each name holds one image or a list of images. A write sends a PNG, JPEG or WebP as a base64 data URL:
import base64
from pathlib import Path
photo = "data:image/png;base64," + base64.b64encode(Path("photo.png").read_bytes()).decode()
ns.write(upsert=[{"id": "listing_7", "attributes": {"kind": "listing"}, "state": {"title": "Oak desk"}, "images": {"photo": photo}}])
The document then holds a reference in its place: {"digest": "sha256:...", "type": "image/png", "width": ..., "height": ...}. To keep the image when you write the document again, send the reference you read. ns.image reads the stored bytes, which are exactly what an engine that reads images reads:
reference = ns.get("listing_7")["images"]["photo"]
data, type = ns.image(reference["digest"])
A judgment reads an image when its context recipe names it as images.<name>, on an engine whose limits in db.engines.list() have images. Any other engine gets the image's digest in its place, and the create's warnings say so. This judgment reads the photo on gpt-6-luna:
ns.judgments.create(
name="photo_matches",
type="bool",
applies_to={"attributes.kind": "listing"},
question="Does the photo show the item that the title describes?",
context={"fields": ["state.title", "images.photo"]},
engine={"name": "gpt-6-luna", "version": "current"},
freshness={"policy": "on_change"},
)
ns.erase_image(digest) erases an image: its bytes are deleted, and documents and evaluations keep its reference, marked "erased": True. It returns {"digest", "erased_at"}, and erasing again returns the same. Reading the image then raises image_erased (410), and a write that sends its bytes again is refused with image_erased.
See Images.
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,503and504, and after a429or503with aRetry-Afterof at most 60 s, 2 times by default (max_retries). A500is retried only for reads, writes and the other calls that are safe to repeat without a key. A call that would create a namespace past the organization's 1,000 a minute gets a429withRetry-Afteruntil the next minute, so it is retried; raisemax_retriesto create many namespaces at once. A413 too_large, such as a write past a namespace's size or attribute-name limit, is never retried. - A
429past a rate limit says which indetails.rate_limit:per_key, orper_orgfor all your organization's API keys together. The per-organization limit counts every process and key, so a retry can meet another429because of your other clients. See limits. ns.judgments.create,updateandbackfillcan 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'sRetry-After, for up towait_timeoutseconds (10 minutes by default). It then returns or raises what the call would have. After the timeout it raisesJobWaitTimeoutError, whosejob["id"]you can pass todb.jobs.wait. Withwait=Falsethe call returns{"accepted": False, "result": ...}or{"accepted": True, "job": ...}.- Requests and responses are plain JSON, typed in
brussle.types. One exception:ns.outcomes.appendtakes the list of outcomes, not the whole request body. - Filters and
rank_byare tuples. - Errors raise
ApiErrorwith the API'scodeanddetails. Thecodeisunknownfor 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 (forns.image, not a PNG, JPEG or WebP). - 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.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| brussle-1.5.0.tar.gz | 141.2 kB | Without provenance | Details for brussle-1.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| brussle-1.5.0-py3-none-any.whl | Python 3 | none | any | Details for brussle-1.5.0-py3-none-any.whl |
Total release size: 230.9 kB
Release files / brussle-1.5.0.tar.gz
| Download URL | brussle-1.5.0.tar.gz |
|---|---|
| Size | 141.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b5830c7933e5281df48d3ce615dfb9aa666e70fa5d830fa1f63bd5b322b382b
|
|
BLAKE2b-256 checksum How to use checksums |
5cf6756f5f98435edc82d94a86bcfac9d7fcce079c096274a7ec56caafa05661
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","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.5.0-py3-none-any.whl
| Download URL | brussle-1.5.0-py3-none-any.whl |
|---|---|
| Size | 89.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
458f449b30a1ecebf3a90da07556e007600889555334f994175a4333027c9267
|
|
BLAKE2b-256 checksum How to use checksums |
912f7d7735026b4bcf976691434bd00fc73345e2dc22aa174d4b84589ea8d2b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","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.5.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.