Skip to main content

A micro-framework for building with LLMs, inspired by LangChain.

Project description

Mini-Chain

Mini-Chain is a micro-framework for building applications with Large Language Models, inspired by LangChain. Its core principle is transparency and modularity, providing a "glass-box" design for engineers who value control and clarity.

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-gpu support for high-performance indexing.

Installation

pip install minichain-ai
#For Local FAISS (CPU) Support:
pip install minichain-ai[local]
#For NVIDIA GPU FAISS Support:
pip install minichain-ai[gpu]
#For Azure Support (Azure AI Search, Azure OpenAI):
pip install minichain-ai[azure]
#To install everything:
pip install minichain-ai[all]

Quick Start Here is the simplest possible RAG pipeline with Mini-Chain:

pip install minichain-ai[local]

from minichain.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 minichain.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 minichain.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 minichain.rag_runner import RAGConfig, RAGRunner
from minichain.chat_models import LocalChatModel, LocalChatConfig
from minichain.embeddings import LocalEmbeddings
from minichain.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()

for azure pip install minichain-ai[azure]

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

fady-0.0.0.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

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

fady-0.0.0-py3-none-any.whl (38.8 kB view details)

Uploaded Python 3

File details

Details for the file fady-0.0.0.tar.gz.

File metadata

  • Download URL: fady-0.0.0.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for fady-0.0.0.tar.gz
Algorithm Hash digest
SHA256 31887c0abe27b910b2b56e7740a10e1cae20f821140b1ca6148b50dbe258cd02
MD5 596a54c21a3a1c9d341a1de8f6fd67c5
BLAKE2b-256 901100412d3992355f86073e86583719488b0a36d2096ac14e6fcfef928eb0a7

See more details on using hashes here.

File details

Details for the file fady-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: fady-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 38.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for fady-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1359b48580c726b19db134938269c19b602849d78316913b5f44af5bdbbe1f1b
MD5 9b90f15260628c8e34b235a711dbcfd3
BLAKE2b-256 d19a67ddc570e5e54ad1fc1c76e9cb90206e7460c887a6c25d8c843e3c5d1a91

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