A local-first, dual-memory engine for AI Agents.
Project description
MemLoop: Local Vector Memory for AI Agents
"Give your AI infinite memory without the API bills."
MemLoop is a production-ready, local-first memory orchestration engine designed to give LLMs (like Gemini, GPT-4, Llama 3) long-term retention capabilities. It bridges the gap between transient context windows and persistent vector storage.
Unlike wrapper libraries, MemLoop implements a custom Dual-Memory Architecture (Short-term buffer + Long-term Vector Store) and runs entirely offline.
Why MemLoop?
- Privacy-First & Offline: Runs 100% locally using
ChromaDBandSentenceTransformers. No OpenAI API keys required. Your data never leaves your machine. - Zero-Latency Caching: Implements an O(1) Semantic Cache that intercepts repeated queries before they hit the Vector DB, reducing retrieval latency by ~99%.
- Citation-Aware Retrieval: Don't just get text; get the source. MemLoop tracks Page Numbers, Row Indices, and URLs so your AI can cite its sources (e.g., "Source: manual.pdf, Page 12").
- Universal Ingestion: Built-in ETL pipeline that automatically ingests:
- Websites (Recursive crawling with
BeautifulSoup) - PDFs & Docs (Automatic text chunking)
- Tabular Data (CSV/Excel linearizer for vector compatibility)
Architecture
MemLoop decouples ingestion from retrieval, using a hybrid cache-first strategy to ensure speed and accuracy.
graph TD
subgraph MemLoop_Engine [MemLoop Core]
Query[User Query] --> Cache{Check Cache?}
Cache -- Hit (0.01ms) --> Response
Cache -- Miss --> VectorDB[(ChromaDB <br/> Local Store)]
VectorDB --> Rerank[Context Reranker]
Rerank --> Response
end
subgraph Ingestion_Layer [ETL Pipeline]
Web[Web Scraper] --> Chunker
Files[PDF/CSV Loader] --> Chunker
Chunker --> Embed[Local Embeddings]
Embed --> VectorDB
end
Quick Start
1. Installation
pip install memloop
2. The Interactive CLI (Chat with your Data)
Launch the built-in terminal interface to test your memory engine instantly.
$ memloop
[SYSTEM]: Initializing Neural Link...
[USER]: /learn https://en.wikipedia.org/wiki/Artificial_intelligence
[SYSTEM]: Success. Absorbed 45 chunks.
[USER]: What is AI?
[MEMLOOP]: "AI is intelligence demonstrated by machines..." (Source: Wikipedia, Chunk 12)
3. Python SDK (Build your own Agent)
Integrate MemLoop into your Python projects in 3 lines of code.
from memloop import MemLoop
# Initialize Brain (Persists to ./memloop_data)
brain = MemLoop()
# A. Ingest Knowledge
print("Ingesting documentation...")
brain.learn_url("https://docs.python.org/3/")
brain.learn_local("./my_documents_folder")
# B. Add Conversation Context
brain.add_memory("User is building a React app.")
# C. Retrieve Context (with Caching & Citations)
context = brain.recall("How do python decorators work?")
print(context)
# Output:
# "Short Term: User is building a React app..."
# "Long Term: [1] Decorators are functions... (Ref: python.org, Section 4.2)"
Integration Example: MemLoop + Gemini
Here is how to use MemLoop as the "Long-Term Memory" for a Gemini (or OpenAI) agent.
import google.generativeai as genai
from memloop import MemLoop
# 1. Setup Memory
brain = MemLoop()
# 2. Setup LLM
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel('gemini-2.5-flash')
def ask_agent(query):
# Retrieve relevant memories locally (Free & Fast)
context = brain.recall(query)
# Send only relevant context to LLM
prompt = f"""
Use the following context to answer the user.
Context: {context}
User: {query}
Answer:
"""
response = model.generate_content(prompt)
return response.text
Supported Formats
| Format | Features |
|---|---|
| .txt / .md | Standard text chunking with overlap. |
| .csv | Row Linearization: Converts rows into narrative sentences for better vector matching. |
| Page Tracking: extracts text while preserving page numbers for citations. | |
| URLs | Smart Scraper: Auto-removes HTML boilerplate (scripts, navbars, ads). |
🗺️ Roadmap
- Local Vector Storage (ChromaDB)
- Semantic Caching (LRU Strategy)
- Web & Local File Ingestion
- Multi-Modal Support (Image Embeddings)
- GraphRAG Integration (Knowledge Graphs)
Contributing
Contributions are welcome! Please open an issue or submit a PR.
- Fork the repo
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
**Built with ❤️ by Vansh**
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 memloop-0.1.0.tar.gz.
File metadata
- Download URL: memloop-0.1.0.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15e6af601b02e1969e0ee8bd6e366c157e0081ae2e278bb51295bf6043873087
|
|
| MD5 |
3135ca772310774e7c283075d97ed60f
|
|
| BLAKE2b-256 |
9cedd2d3669ce308eb6ea67e7f4cb1338580a3f4ff60573038ae24562724e81e
|
File details
Details for the file memloop-0.1.0-py3-none-any.whl.
File metadata
- Download URL: memloop-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71cb7175c67b007355d8d8fc2a595436afdcf47a4f1f594816bce9834140682a
|
|
| MD5 |
e9c6bb5fce21a0d5fa25cfa30fe85310
|
|
| BLAKE2b-256 |
a657baccae4ddd5b3f5871cb2d3dcfc0d40b5a47a0fc0890fa62e19beda11725
|