Python client for the little big brain graph + hybrid search HTTP API
Project description
little big brain Python SDK
The Python client for little big brain. Use it to ingest records, build BM25 + vector + graph indexes, search with authorization filters, traverse the graph, and turn retrieval feedback into training data.
pip install littlebigbrain
Five-minute start
from lbb import LbbClient
with LbbClient(
"https://db.eu.littlebigbrain.com",
api_key="lbb_sk_live_...",
graph="main",
) as lbb:
graph = lbb.graph("main")
graph.facts.create({
"triplets": [{
"source": {"type": "CONCEPT", "name": "handbook", "key": "doc:42"},
"relation": "RELATED_TO",
"target": {"type": "CONCEPT", "name": "vacation policy", "key": "passage:42:1"},
"evidence": "Employees receive 25 days of annual leave.",
}],
}, idempotency_key="doc:42:v1")
lbb.indexes.run(wait=True)
results = lbb.graph_search({
"query": "how much annual leave do employees get?",
"targets": ["entities"],
"top_k": 10,
})
Stack keys belong on a server, worker, or secret-backed notebook—not in a
browser bundle. Safe reads and idempotency-keyed writes retry transient errors
and honor Retry-After.
Enterprise-search integration
For an enterprise-search retrieval adapter, keep the application database for users, connectors, tasks, and migration cursors. Put searchable documents, passages, graph facts, embeddings, BM25/ANN/adjacency indexes, ontology review, and retrieval feedback in LBB.
The production sequence is:
- map a connector batch to stable-keyed document, passage, provenance, and edge records;
- call
graph.facts.import_ndjson(..., index=False, idempotency_key=...); - submit one durable index job with
index_submit, then reconnect withindex_job; - translate the product's ACL/scope filter into native set
overlapsfilters; - call
graph_searchwith projected fields and hydrate only the final top-k; - submit grade-3 feedback for sources cited in the grounded answer;
- evolve ontology changes through draft → validate → promote/reject.
For an LLM query planner, use lbb.context.suggest(...) to fill grounded
schema/value prefixes and lbb.context.resolve(...) to snap free-text guesses
onto real vocabulary. resolve uses the graph's managed embeddings when
configured. Record adopted suggestions and accepted/rejected/corrected plans so
the feedback can train a smaller planner and suggest ranker.
See the complete enterprise-search integration guide for the record model, migration plan, acceptance gates, and capability mapping.
Useful surfaces
# Bulk ingestion (flat or generated typed property values, including sets).
graph.facts.import_ndjson(records, strict=True, index=False,
idempotency_key="connector:batch:17")
# Durable indexing and training.
job = lbb.index_submit({}, idempotency_key="index:head:147")
status = lbb.index_job(job.job_id)
cancelled = lbb.cancel_index_job(job.job_id)
gc = lbb.index_gc_submit({"dry_run": False}, idempotency_key="gc:2026-07-15")
gc_status = lbb.index_gc_job(gc.job_id)
train = lbb.train_submit({"kind": "fusion", "force": True},
idempotency_key="fusion:gate:7")
progress = lbb.train_job(train.job_id).progress
# Typed namespaces.
answer = lbb.context.ask({"question": "what changed?"})
ontology = lbb.ontology.view(counts=True)
rows = lbb.query.sparql({"query": "SELECT ?s WHERE { ?s ?p ?o }"})
# Cursor-safe iteration.
for entity in lbb.entities.iter(fields=["text", "acl"]):
print(entity.name, entity.attributes)
# Branch deletion protects the final live branch; graph deletion removes all branches.
lbb.graph("main", branch="review").delete_branch(confirm="review")
lbb.graph("main").delete(confirm="main")
LbbClient and AsyncLbbClient expose the same capabilities. Preferred
namespaces return generated Pydantic models; compatibility helpers return
parsed dictionaries. LbbError includes HTTP status, structured code,
parameter, request ID, and documentation URL. raw_request(...) exposes
attempt count, elapsed time, response headers, build commit, and replica.
Major capability areas
graph(...).facts: commit, dry-run, retract, NDJSON/RDF importsearch/graph_search: lexical, BM25, vector, hybrid, filters, facetsindexes: full build, durable submit/status, delta, garbage collectionentities: projected reads, native filtering, cursor-safe iterationontology/schema: define, evolve, induce, draft review, SHACL lifecyclequery: SPARQL, structured query, analytics, SHACL, inference, conflictscontext: grounded ask, suggest, resolve, decode, groundability- feedback/training: labels, export/summary, durable trainer jobs and progress; typed suggestion/planner supervision helpers with validation before transport, automatic idempotency keys, and durable receipt/trainability acknowledgements
- temporal graph: traversal, state, history, lineage, snapshot pins
Generated models come from the bundled OpenAPI contract and are available in
lbb.models.
Develop
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]" httpx pydantic
ruff check lbb tests
mypy lbb
pytest tests
lbb/models.py is generated. Change the Rust API types and regenerate clients
instead of editing it by hand.
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 littlebigbrain-0.6.0.tar.gz.
File metadata
- Download URL: littlebigbrain-0.6.0.tar.gz
- Upload date:
- Size: 128.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fb9cec62584039ee3cba6186d61472acc4ea2eceab72d0e78c9636f8c3ab4ab
|
|
| MD5 |
45b95189f56494dd2ab36fdc5c298548
|
|
| BLAKE2b-256 |
6cfcd271b9fbdfa389a488e50237a9de7d9bd08856a86f2ab862576d8507bd1c
|
Provenance
The following attestation bundles were made for littlebigbrain-0.6.0.tar.gz:
Publisher:
release.yml on littlebigbrains/lbb-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
littlebigbrain-0.6.0.tar.gz -
Subject digest:
8fb9cec62584039ee3cba6186d61472acc4ea2eceab72d0e78c9636f8c3ab4ab - Sigstore transparency entry: 2186409405
- Sigstore integration time:
-
Permalink:
littlebigbrains/lbb-python@3150adc28ab14d8f305eba371fc405f3c2256d4d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/littlebigbrains
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3150adc28ab14d8f305eba371fc405f3c2256d4d -
Trigger Event:
push
-
Statement type:
File details
Details for the file littlebigbrain-0.6.0-py3-none-any.whl.
File metadata
- Download URL: littlebigbrain-0.6.0-py3-none-any.whl
- Upload date:
- Size: 112.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95124a18593db2393494fd10dca1b8600c3a94a7ff49bee3fb3a830a47968e34
|
|
| MD5 |
746c472c39a1ad95f6a8539d286a31f7
|
|
| BLAKE2b-256 |
e3f9db3c1898856fba4e355f79ba8259dd875d5bf150a200ac2113599cfe7f39
|
Provenance
The following attestation bundles were made for littlebigbrain-0.6.0-py3-none-any.whl:
Publisher:
release.yml on littlebigbrains/lbb-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
littlebigbrain-0.6.0-py3-none-any.whl -
Subject digest:
95124a18593db2393494fd10dca1b8600c3a94a7ff49bee3fb3a830a47968e34 - Sigstore transparency entry: 2186409556
- Sigstore integration time:
-
Permalink:
littlebigbrains/lbb-python@3150adc28ab14d8f305eba371fc405f3c2256d4d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/littlebigbrains
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3150adc28ab14d8f305eba371fc405f3c2256d4d -
Trigger Event:
push
-
Statement type: