Mini-Chain
Mini-Chain is a micro-framework for building applications with Large Language Models, inspired by LangChain.
Core Features
- Modular Components: Swappable classes for Chat Models, Embeddings, Memory, and more.
- Local & Cloud Ready: Supports both local models (via LM Studio) and cloud services (Azure).
- Modern Tooling: Built with Pydantic for type-safety and Jinja2 for powerful templating.
- GPU Acceleration: Optional
faiss-gpusupport for high-performance indexing.
Installation
pip install chain-ai
#For Local FAISS (CPU) Support:
pip install chain-ai[local]
#For NVIDIA GPU FAISS Support:
pip install chain-ai[gpu]
#For pdf parser(pymupdf)
pip install chain-ai[pdf]
#For Azure Support (Azure AI Search, Azure OpenAI):
pip install chain-ai[azure]
#To install everything:
pip install chain-ai[all]
Quick Start Here is the simplest possible RAG pipeline with Mini-Chain:
pip install chain-ai[local]
from chain.rag_runner import create_rag_from_files
# Load knowledge from files
rag = create_rag_from_files(
file_paths=["path/manual.txt", "README.md"],
system_prompt="You are a documentation assistant.",
chunk_size=500,
retrieval_k=3
)
rag.run_chat()
To Read the full directory
from chain.rag_runner import create_rag_from_directory
# Load all Python files from a directory
rag = create_rag_from_directory(
directory="./src",
file_extensions=['.py', '.md'],
system_prompt="You are a code assistant."
)
rag.run_chat()
Custom RAG Configuration
from chain.rag_runner import RAGRunner, RAGConfig
config = RAGConfig(
knowledge_texts=["Your knowledge here..."],
knowledge_files=["file1.txt", "file2.md"],
# Chunking settings
chunk_size=1000,
chunk_overlap=200,
# Retrieval settings
retrieval_k=4,
similarity_threshold=0.7, # Only include high-similarity results
# Chat settings
system_prompt="Custom system prompt...",
conversation_keywords=["custom", "keywords", "for", "conversation", "detection"],
# Components (optional - uses defaults if not provided)
chat_model=None, # Will use LocalChatModel
embeddings=None, # Will use LocalEmbeddings
text_splitter=None, # Will use RecursiveCharacterTextSplitter
vector_store=None, # Will create FAISSVectorStore
debug=True # Enable debug output
)
rag = RAGRunner(config).setup()
rag.run_chat()
Using Custom Components
from chain.rag_runner import RAGConfig, RAGRunner
from chain.chat_models import LocalChatModel, LocalChatConfig
from chain.embeddings import LocalEmbeddings
from chain.text_splitters import RecursiveCharacterTextSplitter
# Custom components
custom_model = LocalChatModel(LocalChatConfig(temperature=0.7))
custom_embeddings = LocalEmbeddings()
custom_splitter = RecursiveCharacterTextSplitter(chunk_size=800)
config = RAGConfig(
knowledge_texts=["Your knowledge..."],
chat_model=custom_model,
embeddings=custom_embeddings,
text_splitter=custom_splitter,
)
rag = RAGRunner(config).setup()
rag.run_chat()
pip install chain-ai[pdf]
from chain.rag_runner import create_smart_rag
# Load PDF and create RAG
rag = create_smart_rag(knowledge_files=["resume.pdf"])
# Query the PDF
response = rag.query("Can he vibe code ?")
print(response)
for azure ai search pip install chain-ai[azure]
Release files for chain-ai 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| chain_ai-0.0.1.tar.gz | 31.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| chain_ai-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 72.2 kB
Release files / chain_ai-0.0.1.tar.gz
| Download URL | chain_ai-0.0.1.tar.gz |
|---|---|
| Size | 31.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
24488194c56716b362455aba93ab13f7dad0c944351e1bbdf2ae3191edf3bfcf
|
|
BLAKE2b-256 checksum How to use checksums |
f02e37b1de38c7ba854905c7cdc50d6e6038da1f2b6f6de9a01f878d095ceb5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.18
|
Release files / chain_ai-0.0.1-py3-none-any.whl
| Download URL | chain_ai-0.0.1-py3-none-any.whl |
|---|---|
| Size | 40.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
477a904ea374617a6eabb3b960454f2989757424d0295f5fc9900ead03e9d62d
|
|
BLAKE2b-256 checksum How to use checksums |
d586e85c68cf12bdee9ed4eadbe71e090fd8127eb2fc2eb00e8bd8b6444862d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.18
|