Zero-dependency LLM framework. LangChain in 800 lines. Built like a rock.
Project description
StoneChain
The zero-dependency LLM framework. LangChain in 800 lines. Built like a rock.
Why?
LangChain is bloated. 200+ dependencies. 100,000+ lines. Abstraction hell.
StoneChain does the same thing in one file with zero dependencies.
| LangChain | StoneChain | |
|---|---|---|
| Core dependencies | 200+ | 0 |
| Install size | 50MB+ | 36KB |
| Lines of code | 100,000+ | ~800 |
| Time to understand | Days | Minutes |
Install
# Option 1: Copy the file (recommended)
curl -O https://raw.githubusercontent.com/KentStone/stonechain/main/stonechain.py
# Option 2: pip
pip install stonechain
Quick Start
from stonechain import Anthropic
# That's it. No config. No setup.
llm = Anthropic() # Uses ANTHROPIC_API_KEY env var
print(llm("What is 2+2?")) # "4"
Providers
from stonechain import Anthropic, OpenAI, Groq, Mistral, DeepSeek, Ollama
# Cloud providers (need API keys)
llm = Anthropic() # claude-sonnet-4-20250514
llm = OpenAI() # gpt-4o
llm = Groq() # llama-3.3-70b-versatile
llm = Mistral() # mistral-large-latest
llm = DeepSeek() # deepseek-chat
# Local (no API key needed)
llm = Ollama(model="llama3.2") # Any Ollama model
Core Features
Chain (Sequential Calls)
from stonechain import Anthropic, Chain
chain = Chain(Anthropic())
chain.add("analyze", "Analyze: {input}", "analysis")
chain.add("critique", "Critique: {analysis}", "critique")
result = chain.run(input="AI safety")
Agent (Tool Use)
from stonechain import Anthropic, Agent, Tool
def calculator(expression: str) -> str:
return str(eval(expression))
agent = Agent(Anthropic(), [
Tool("calculator", "Do math", {"expression": {"type": "string"}}, calculator)
])
result = agent.run("What is 15 * 23?")
RAG (Document Q&A)
from stonechain import Anthropic, RAG, Document
rag = RAG(Anthropic())
rag.add([Document("StoneChain was created by Kent Stone.")])
answer = rag.query("Who created StoneChain?")
Conversation (Memory)
from stonechain import Anthropic, Conversation
conv = Conversation(Anthropic(), system="You are a pirate.")
print(conv.chat("Hello!")) # "Ahoy, matey!"
Vector Database Integrations
For production RAG, use stonechain_vectors.py with your preferred vector DB:
from stonechain import Anthropic
from stonechain_vectors import VectorRAG, ChromaStore, OpenAIEmbeddings
# Production RAG with Chroma + OpenAI embeddings
rag = VectorRAG(
llm=Anthropic(),
store=ChromaStore(persist_directory="./my_db"),
embeddings=OpenAIEmbeddings()
)
rag.add(["Document 1", "Document 2", "Document 3"])
answer = rag.query("What's in document 1?")
Supported Vector Databases
| Database | Install | Usage |
|---|---|---|
| Pinecone | pip install pinecone-client |
PineconeStore(api_key="...", index_name="...") |
| Chroma | pip install chromadb |
ChromaStore(persist_directory="./db") |
| Weaviate | pip install weaviate-client |
WeaviateStore(url="http://localhost:8080") |
| Qdrant | pip install qdrant-client |
QdrantStore(url="http://localhost:6333") |
| Milvus | pip install pymilvus |
MilvusStore(host="localhost") |
| PostgreSQL | pip install psycopg2-binary pgvector |
PgVectorStore(connection_string="...") |
Supported Embedding Providers
| Provider | Env Var | Usage |
|---|---|---|
| OpenAI | OPENAI_API_KEY |
OpenAIEmbeddings(model="text-embedding-3-small") |
| Cohere | COHERE_API_KEY |
CohereEmbeddings(model="embed-english-v3.0") |
| Voyage AI | VOYAGE_API_KEY |
VoyageEmbeddings(model="voyage-2") |
MCP Support (Model Context Protocol)
StoneChain includes zero-dependency MCP support:
MCP Client
from stonechain import Anthropic, Agent
from stonechain_mcp import MCPClient, StdioTransport, HTTPTransport
client = MCPClient({
"math": StdioTransport("python", ["math_server.py"]),
"weather": HTTPTransport("http://localhost:8000/mcp"),
})
tools = await client.get_tools()
agent = Agent(Anthropic(), tools)
MCP Server (FastMCP Alternative)
from stonechain_mcp_server import MCPServer
server = MCPServer("Math")
@server.tool()
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b
server.run()
File Structure
stonechain/
├── stonechain.py # Core (zero deps) - LLM, Chain, Agent, RAG
├── stonechain_vectors.py # Vector DBs (optional deps) - Pinecone, Chroma, etc.
├── stonechain_mcp.py # MCP client (zero deps)
└── stonechain_mcp_server.py # MCP server (zero deps)
Philosophy: Core has zero dependencies. Extensions are optional.
Environment Variables
# LLM Providers
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
GROQ_API_KEY=gsk_...
MISTRAL_API_KEY=...
DEEPSEEK_API_KEY=...
# Embedding Providers (for stonechain_vectors)
COHERE_API_KEY=...
VOYAGE_API_KEY=...
Documentation
- Migration Guide - Moving from LangChain
- Advanced Usage - Custom providers, agents, RAG
Why "StoneChain"?
- Stone - Built solid. No flaky dependencies.
- Stone - The author's name (Kent Stone)
- Chain - LLM orchestration
License
MIT License - do whatever you want.
Author
Kent Stone (@KentStone)
Creator of JARVIS Cognitive AI and the Stone Retrieval Function (SRF).
Built like a rock. Zero dependencies. Zero excuses. 🪨
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 stonechain-1.0.0.tar.gz.
File metadata
- Download URL: stonechain-1.0.0.tar.gz
- Upload date:
- Size: 43.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7d66408aabb48b4d02303128716248c48909bab103f607fed4efbbcd0b224a8
|
|
| MD5 |
260e5670823b90fce718fa5264e845cb
|
|
| BLAKE2b-256 |
d0e5dc71b954af63a4b454a647251f0d4bf92a600ec20df85765e63a4de903bf
|
Provenance
The following attestation bundles were made for stonechain-1.0.0.tar.gz:
Publisher:
ci.yml on kentstone84/StoneChain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stonechain-1.0.0.tar.gz -
Subject digest:
b7d66408aabb48b4d02303128716248c48909bab103f607fed4efbbcd0b224a8 - Sigstore transparency entry: 763596954
- Sigstore integration time:
-
Permalink:
kentstone84/StoneChain@afde56a294b16f8f9dc542d2f82cbf6859756022 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/kentstone84
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@afde56a294b16f8f9dc542d2f82cbf6859756022 -
Trigger Event:
push
-
Statement type:
File details
Details for the file stonechain-1.0.0-py3-none-any.whl.
File metadata
- Download URL: stonechain-1.0.0-py3-none-any.whl
- Upload date:
- Size: 51.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
115fc617f77ff672ada6dcdf1decd7ce0d499f36d34625b7b4b504bf6cd005e0
|
|
| MD5 |
296bb6454770ce9d4789e8dcb3713b11
|
|
| BLAKE2b-256 |
b777053b379010e55f608eb64ed15b1f3de264d2a2a67c198d927eab9a9f74c7
|
Provenance
The following attestation bundles were made for stonechain-1.0.0-py3-none-any.whl:
Publisher:
ci.yml on kentstone84/StoneChain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stonechain-1.0.0-py3-none-any.whl -
Subject digest:
115fc617f77ff672ada6dcdf1decd7ce0d499f36d34625b7b4b504bf6cd005e0 - Sigstore transparency entry: 763596956
- Sigstore integration time:
-
Permalink:
kentstone84/StoneChain@afde56a294b16f8f9dc542d2f82cbf6859756022 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/kentstone84
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@afde56a294b16f8f9dc542d2f82cbf6859756022 -
Trigger Event:
push
-
Statement type: