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 - Program — Compose multi-step workflows
- 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
- Complete execution history for debugging
- Multi-step workflows with Program
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?")
# Debug with history
print(qa.history[0].inputs) # See what was sent
print(qa.lm.history[0].usage) # Check token usage
Cookbook
Check out the cookbook/ directory for hands-on examples:
LM Integrations:
lm/ollama.ipynb- Ollama integration with vision supportlm/bedrock.ipynb- AWS Bedrock integration
Predictor Patterns:
predictor/zero_shot.ipynb- Basic prompting and chain-of-thoughtpredictor/few_shots.ipynb- Few-shot learning with examples
Program Workflows:
program/simple_program.ipynb- Multi-step workflows with tracking
What's Next?
Check out ROADMAP.md for what's coming and VERSIONS.md for release notes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file brokit-0.1.2.tar.gz.
File metadata
- Download URL: brokit-0.1.2.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce44a898c4e4f101be2b656fa00c38b436af6b210dcf7adfe37806618367762a
|
|
| MD5 |
0c9cbfb27acec778b59f5ad296e7b556
|
|
| BLAKE2b-256 |
d57106656cd9bec72108b6db016c20c555b7b319a76e32cd5a460f1f3f7ca485
|
File details
Details for the file brokit-0.1.2-py3-none-any.whl.
File metadata
- Download URL: brokit-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db92a8ca5f1d8ef61ca7b0f3b0512dc9f251706b5b2c817d06a6231fa0814ea0
|
|
| MD5 |
590b2c92ffc2833b8c80d0545152cf64
|
|
| BLAKE2b-256 |
9373d5890178b36aaa4ea6e33d463338ff5ef6d68ac4d74c2d70fbe558ce019e
|