Skip to main content

Bench — the home for your AI agents. One line of code → live dashboard, public profile, README badge.

Project description

bench-sdk (Python)

Python SDK for Bench — the home for your AI agents.

pip install bench-observe

Usage

import asyncio
from bench import observe

agent = observe(api_key="bk_xxx", agent="my-agent")

async def search(t):
    result = await do_search()
    t.log("found", len(result))
    t.cost(0.004)
    return result

async def main():
    result = await agent.task("search", {"query": "python"}, search)

asyncio.run(main())

Context manager

async with agent.task_ctx("summarize", {"doc": url}) as t:
    summary = await llm.generate(prompt)
    t.log("tokens", 1200)
    t.cost(0.012)

Subtasks

async def pipeline(t):
    await t.subtask("fetch", {"url": url}, fetch_fn)
    await t.subtask("parse", {"html": html}, parse_fn)
    await t.subtask("embed", {"text": text}, embed_fn)

await agent.task("full-pipeline", input, pipeline)

Custom events

agent.event("tool.use", {"tool": "search", "query": q})

LangChain adapter

pip install bench-langchain
from bench import observe
from bench_langchain import BenchCallbackHandler

agent = observe(api_key="bk_xxx", agent="my-langchain-agent")
handler = BenchCallbackHandler(agent)

# Every chain/LLM/tool call is now a traced Bench task
chain.invoke({"input": "..."}, config={"callbacks": [handler]})

After one run you get a live dashboard, public profile, and README badge — no other setup.

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

bench_observe-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

bench_observe-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bench_observe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6d62a74c5ddc15e655b019b5181e5716ec57243ac522da36f023fc8c3b97647e
MD5 d3b90020f5b6172636ebcd2751139dc1
BLAKE2b-256 712545ac9edc8f328755d78a2e10cf1f168b0fcfb4236c8e9af871b8825687a6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for bench_observe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c4806077a5ab40b939899ae6f1e0ad57427ee4cbb625db3cb15dbdf71d4f242
MD5 bcd276463683d8bd1f25e72de7d944c2
BLAKE2b-256 e466d66bcfa90f0ad48246a2653ca537344dd7fdfacb356d9d897fd5dc7cdfdb

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