Skip to main content

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:

  1. map a connector batch to stable-keyed document, passage, provenance, and edge records;
  2. call graph.facts.import_ndjson(..., index=False, idempotency_key=...);
  3. submit one durable index job with index_submit, then reconnect with index_job;
  4. translate the product's ACL/scope filter into native set overlaps filters;
  5. call graph_search with projected fields and hydrate only the final top-k;
  6. submit grade-3 feedback for sources cited in the grounded answer;
  7. evolve ontology changes through draft → validate → promote/reject.

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)
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)

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 import
  • search / graph_search: lexical, BM25, vector, hybrid, filters, facets
  • indexes: full build, durable submit/status, delta, garbage collection
  • entities: projected reads, native filtering, cursor-safe iteration
  • ontology / schema: define, evolve, induce, draft review, SHACL lifecycle
  • query: SPARQL, structured query, analytics, SHACL, inference, conflicts
  • context: grounded ask, suggest, resolve, decode, groundability
  • feedback/training: labels, export/summary, durable trainer jobs and progress
  • 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


Download files

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

Source Distribution

littlebigbrain-0.4.4.tar.gz (112.8 kB view details)

Uploaded Source

Built Distribution

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

littlebigbrain-0.4.4-py3-none-any.whl (101.0 kB view details)

Uploaded Python 3

File details

Details for the file littlebigbrain-0.4.4.tar.gz.

File metadata

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

File hashes

Hashes for littlebigbrain-0.4.4.tar.gz
Algorithm Hash digest
SHA256 e654864a9ee64e27b41927e59be73074fabd724777f30b10420b2faf9a42f0ac
MD5 b857fa2be41638ceb416a45a61c175e0
BLAKE2b-256 b88029b0ac2dd31cf785025bd84d18bba798c3057bd8081d385fd97ea66a25cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for littlebigbrain-0.4.4.tar.gz:

Publisher: release.yml on littlebigbrains/lbb-python

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

File details

Details for the file littlebigbrain-0.4.4-py3-none-any.whl.

File metadata

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

File hashes

Hashes for littlebigbrain-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 425245e43fed9b308426dc63dbfd7c24c601cdc6a3a337e9468e965e2f852986
MD5 7fa1f4d22a44a35a4c53fc72fb09b748
BLAKE2b-256 ba7605b0d8d277dfb5988272aab6b625618d3ce3680575d7fa3d5e80af8530bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for littlebigbrain-0.4.4-py3-none-any.whl:

Publisher: release.yml on littlebigbrains/lbb-python

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