srush/MiniChain
A minimal Python library for composing LLM calls via decorated functions with graph-based debugging and prompt templating.

MiniChain lets developers annotate Python functions with a @prompt decorator to call LLMs, separating prompts from code using templates. It builds a computational graph of all LLM invocations (similar to PyTorch) for debugging and error handling, and allows chaining multiple LLM calls together to build complex workflows. The library supports various LLM backends like OpenAI and includes built-in examples like Retrieval-Augmented QA and math reasoning chains.