Skip to main content

brokit, think it like a playing lego

Project description

brokit

Inspired by big bro DSPy, brokit is a minimal Python toolkit of composable, LEGO-like primitives for working with language models. Build what you need, skip the bloat.

What's This About?

A lightweight library for working with LMs across any use case. Just the essential building blocks, nothing more.

Core Concepts

Coming from DSPy? You already know what's up:

  • Prompt = dspy.Signature — Define your input/output structure
  • Predictor = dspy.Predict — Execute prompts with your LM
  • LM = dspy.LM — Language model interface
  • Shot — Few-shot examples made simple

Design Philosophy

Plug and Play

Everything's a base class. Compose, extend, swap out whatever you want. The LM module? Bring your own.

Pure Python

Zero required dependencies. Want to use requests, httpx, or boto3? Go for it. Check the notebooks for integration examples.

Features

  • Text and image support (more formats coming)
  • Few-shot learning with Shot
  • Build custom LM implementations
  • Structured prompts with type hints

Installation

pip install brokit

Quick Start

import brokit as bk

# Define your prompt structure
class QA(bk.Prompt):
    """Answer questions"""
    question: str = bk.InputField()
    answer: str = bk.OutputField()

# Create your LM and predictor
lm = YourLM(model_name="your-model")
qa = bk.Predictor(prompt=QA, lm=lm)

# Get results
response = qa(question="What is brokit?")

Cookbook

Check out the cookbook/ directory for hands-on examples:

LM Integrations:

  • lm/ollama.ipynb - Ollama integration with vision support
  • lm/bedrock.ipynb - AWS Bedrock integration

Predictor Patterns:

  • predictor/zero_shot.ipynb - Basic prompting and chain-of-thought
  • predictor/few_shots.ipynb - Few-shot learning with examples

What's Next?

Check out ROADMAP.md for what's coming and VERSIONS.md for release notes.

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

brokit-0.1.1.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

brokit-0.1.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file brokit-0.1.1.tar.gz.

File metadata

  • Download URL: brokit-0.1.1.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for brokit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 744421d6691c8ff925ba566e5eb042371fa821886f3661a81e6f25947d30a159
MD5 0498c50695dd6053c6c93e9f55b94a78
BLAKE2b-256 fa7420d5d5da70b47916a7dfa33fc3334f3fab3bb06f49601729ec9f04ff42a5

See more details on using hashes here.

File details

Details for the file brokit-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: brokit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for brokit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d77e43ff94fc924806ff8276ee1ec6224a197a5765a51780669a92c80f2ca774
MD5 b1cc58f7b3d96def8c5a5a832dfb2540
BLAKE2b-256 888b8bedf1a6b5339213a66979012c6e6b3f3c2fc656e634cd2d8fecdedc241d

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