GraphCanon updated today · GitHub synced today
Trust & integrity
Full report- Maintenance
- Dormant (730d since push)
- As of today · Source: github_public_v1
- Provenance
- Not a fork · Personal account
- As of today · Source: github_public_v1
- Security (OSV)
- No lockfile
- As of today · Source: none
Public GitHub metadata and optional OSV dependency scans. Signals, not a guarantee. Trust methodology.
Overview
A tiny library for coding with large language models.
Capability facts
- Languages
- python
Source: github.language · Jul 11, 2026
Categories
Compatibility
Sourced claims from the README excerpt - not unsourced marketing copy.
Source: README excerpt (regex_v1, Jul 11, 2026)
notably: [LangChain](https://langchain.readthedocs.io/en/latest/),Source link
Source: README excerpt (regex_v1, Jul 11, 2026)
(https://github.com/srush/MiniChain/blob/main/examples/math_demo.py)): Annotate Python functions that call language models.Source link
Source: README excerpt (regex_v1, Jul 11, 2026)
* [Chat with memory](https://srush.github.io/MiniChain/examples/chatgpt/)Source link
Tags
README
A tiny library for coding with large language models. Check out the MiniChain Zoo to get a sense of how it works.
Coding
- Code (math_demo.py): Annotate Python functions that call language models.
@prompt(OpenAI(), template_file="math.pmpt.tpl")
def math_prompt(model, question):
"Prompt to call GPT with a Jinja template"
return model(dict(question=question))
@prompt(Python(), template="import math\n{{code}}")
def python(model, code):
"Prompt to call Python interpreter"
code = "\n".join(code.strip().split("\n")[1:-1])
return model(dict(code=code))
def math_demo(question):
"Chain them together"
return python(math_prompt(question))
- Chains (Space): MiniChain builds a graph (think like PyTorch) of all the calls you make for debugging and error handling.
show(math_demo,
examples=["What is the sum of the powers of 3 (3^i) that are smaller than 100?",
"What is the sum of the 10 first positive integers?"],
subprompts=[math_prompt, python],
out_type="markdown").queue().launch()
- Template (math.pmpt.tpl): Prompts are separated from code.
...
Question:
A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?
Code:
2 + 2/2
Question:
{{question}}
Code:
- Installation
pip install minichain
export OPENAI_API_KEY="sk-***"
Examples
This library allows us to implement several popular approaches in a few lines of code.
- Retrieval-Augmented QA
- Chat with memory
- Information Extraction
- Interleaved Code (PAL) - (Gao et al 2022)
- Search Augmentation (Self-Ask) - (Press et al 2022)
- Chain-of-Thought - (Wei et al 2022)
It supports the current backends.
- OpenAI (Completions / Embeddings)
- Hugging Face 🤗
- Google Search
- Python
- Manifest-ML (AI21, Cohere, Together)
- Bash
Why Mini-Chain?
There are several very popular libraries for prompt chaining, notably: LangChain, Promptify, and GPTIndex. These library are useful, but they are extremely large and complex. MiniChain aims to implement the core prompt chaining functionality in a tiny digestable library.
Tutorial
Mini-chain is based on annotating functions as prompts.
@prompt(OpenAI())
def color_prompt(model, input):
return model(f"Answer 'Yes' if this is a color, {input}. Answer:")
Prompt functions act like python functions, except they are lazy to access the result you need to call run().
if color_prompt("blue").run() == "Yes":
print("It's a color")
Alternatively you can chain prompts together. Prompts are lazy, so if you want to manipulate them you need to add @transform() to your function. For example:
@transform()
def said_yes(input):
return input == "Yes"
@prompt(OpenAI())
def adjective_prompt(model, input):
return model(f"Give an adjective to describe {input}. Answer:")
ad