Skip to content

feat: add brain context() recall to the Python SDK (v0.2.0)#11

Merged
mishanefedov merged 1 commit into
mainfrom
add-context-method
Jun 15, 2026
Merged

feat: add brain context() recall to the Python SDK (v0.2.0)#11
mishanefedov merged 1 commit into
mainfrom
add-context-method

Conversation

@mishanefedov

@mishanefedov mishanefedov commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds context() — the brain's primary recall API (GET /v1/brain/context) — to the Python SDK. Previously only search/write/get were wrapped, so callers had to drop to raw httpx for prompt-ready recall.\n- New ContextResponse/ContextHit types (snake_case with wire aliases, extra=allow for forward-compat).\n- Wired into sync + async DocumentsResource, the UnisonBrain/AsyncUnisonBrain convenience methods, and the raw wrappers; exported from the package.\n- Bumped to 0.2.0.\n\n## Test plan\n- [x] test_context added; full suite passes (61 tests)\n- [x] live-tested against a running brain: client.context("…") returns ContextResponse (weak_evidence, hits[].snippet, context_md, top_score) and abstains on weak queries

Summary by cubic

Adds prompt-ready recall via context() to the Python SDK by wrapping GET /v1/brain/context across sync, async, and raw clients. Introduces typed responses and bumps unisonlabs to 0.2.0.

  • New Features

    • context() available on UnisonBrain, AsyncUnisonBrain, DocumentsResource, and raw wrappers.
    • Supports k, mode, max_entities, path_prefix, include_bodies (mapped to API aliases).
    • New types: ContextResponse and ContextHit (snake_case fields with wire aliases, extra=allow).
    • Returns context_md, weak_evidence, hits, top_score, and entities; includes test coverage.
  • Migration

    • Upgrade to unisonlabs 0.2.0 and call client.context("your query") instead of hand-rolling HTTP calls.

Written for commit fe32da8. Summary will update on new commits.

Review in cubic

@mishanefedov mishanefedov merged commit 2b95ed1 into main Jun 15, 2026
@mishanefedov mishanefedov deleted the add-context-method branch June 15, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant