Skip to main content

Official Python SDK for Breeth, a memory layer for agents.

Project description

breeth

Official Python SDK for Breeth, the memory layer for agents.

breeth is a thin, type-safe wrapper around the Breeth REST API. It ships with both a synchronous and an asynchronous client, runs on Python 3.10+, and depends only on httpx and pydantic.

Install

pip install breeth

Quickstart (sync)

from breeth import BreethClient

with BreethClient(api_key="ck_live_...") as breeth:
    # Write a memory
    write_resp = breeth.write(
        "Candidate Jane Doe has 4 years HR-tech experience at Workday.",
        group_id="recruiting",
    )
    print(write_resp.episode_name, write_resp.extracted.entities)

    # Retrieve
    results = breeth.retrieve("HR-tech background", group_id="recruiting", limit=5)
    for edge in results.edges:
        print(edge.fact)

    # Inspect an entity
    entity = breeth.entity("Workday", mode="narrative")

    # Browse the graph
    nodes = breeth.graph.list_entities(query="Jane", limit=25)
    edges = breeth.graph.list_edges(limit=50)
    eps = breeth.graph.list_episodes()
    details = breeth.graph.node_details(nodes.entities[0].uuid)

    # List groups visible to the team
    groups = breeth.groups()

Quickstart (async)

import asyncio
from breeth import AsyncBreethClient

async def main():
    async with AsyncBreethClient(api_key="ck_live_...") as breeth:
        await breeth.write("Recruiter prefers iterative sourcing.")
        results = await breeth.retrieve("recruiter preferences")
        print(results.edges)

asyncio.run(main())

Configuration

Setting Source
API key api_key= argument, then BREETH_API_KEY env var, then COGRAM_API_KEY
Base URL base_url= argument, then COGRAM_API_URL env var, default https://api.thebreeth.com
End user passthrough end_user_id= argument, sent as X-End-User-Id

Errors

Every non-2xx response is raised as a BreethError:

from breeth import BreethClient, BreethError

try:
    with BreethClient(api_key="ck_live_...") as breeth:
        breeth.write("...")
except BreethError as err:
    print(err.status)   # 429
    print(err.slug)     # "quota_exceeded"
    print(err.message)  # "Monthly write quota exceeded."
    print(err.body)     # raw JSON payload

The slug field is stable across API versions, so it is safe to branch on it.

Roadmap

  • v0.1.0: sync + async clients for write, retrieve, entity, graph, groups.
  • v0.2.0: NDJSON streaming endpoints (/v1/graph/nodes, /v1/graph/links).

Links

License

MIT. See LICENSE.

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

breeth-0.1.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

breeth-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file breeth-0.1.0.tar.gz.

File metadata

  • Download URL: breeth-0.1.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for breeth-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e49d568aa5714af8622435378f81df804e0d03081af46650653c220ad2634ff5
MD5 c50013dc5e125b65766f3927502e4caa
BLAKE2b-256 82c74ca78f52e76c586be66ae1adb047b18cf32740ae830f2892163b30c855d1

See more details on using hashes here.

File details

Details for the file breeth-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: breeth-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for breeth-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38a5e5ccf3ec0b07d7ede074b8b88aff29a7e7b64a230061dd626bda36241d57
MD5 2553384ece71bc68f0450a3b3e574010
BLAKE2b-256 04e56c8ceda770da50d496d33c132530959cceff0056a2a6d3503743408668c1

See more details on using hashes here.

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