A local-first, dual-memory engine for AI Agents.
Project description
MemLoop
The Plug-and-Play Memory Engine for AI Agents.
MemLoop is a local-first Python library that gives LLMs "Infinite Memory". It ingests documents (PDF, CSV, TXT) and websites, stores them in a local vector database, and retrieves them with citation-style mapping.
No API keys required. 100% Offline Capable.
Quick Start
Installation
pip install memloop
The 30-Second Demo (Interactive CLI)
memloop
Build Your First RAG Agent (The 20-Line Tutorial)
Retrieval-Augmented Generation (RAG) usually requires setting up Vector DBs, Embedding Models, and Retrievers. MemLoop handles that complexity so you can focus on the logic.
With Gemini
import google.generativeai as genai
from memloop import MemLoop
# --- Configuration ---
genai.configure(api_key="YOUR_GEMINI_API_KEY")
model = genai.GenerativeModel('gemini-pro')
brain = MemLoop()
# --- Step 1: Ingest (Run once, persist forever) ---
# brain.learn_url("https://docs.python.org/3/glossary.html")
# --- Step 2: Retrieve ---
query = "What is a decorator in Python?"
context = brain.recall(query) # <--- MemLoop does the heavy lifting
# --- Step 3: Generate ---
prompt = f"Use this context to answer:\n{context}\n\nUser: {query}"
response = model.generate_content(prompt)
print(response.text)
With OpenAI
from openai import OpenAI
from memloop import MemLoop
client = OpenAI(api_key="YOUR_KEY")
brain = MemLoop()
# brain.learn_local("./my_docs")
query = "Summarize the documents."
context = brain.recall(query)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": f"Context:\n{context}\n\nQ: {query}"}]
)
print(response.choices[0].message.content)
API Reference
MemLoop()
The main entry point. Initializes the local vector store (ChromaDB) in ./memloop_data.
brain = MemLoop(db_path="./custom_folder")
.learn_url(url: str)
Scrapes a webpage, cleans the HTML, chunks the text, and stores vectors locally.
- Returns:
int(Number of chunks ingested).
.learn_local(folder_path: str)
Recursively ingests a local folder. Supports .pdf (with page tracking), .csv (row linearization), .txt, and .md.
- Returns:
int(Number of documents processed).
.recall(query: str)
Retrieves the most relevant context.
- Checks Semantic Cache (O(1) return if query is repeated).
- If miss, performs Vector Search (Cosine Similarity).
- Returns formatted string with Citations.
Pro Tip: The "Persistent Brain"
Because MemLoop uses ChromaDB locally, you don't need to run .learn_url every time!
Run the script once to learn:
brain.learn_url("https://docs.python.org") # Run this ONCE
Then comment it out. Your agent now "remembers" that data forever in future runs.
Technology Stack
- Vector Querying: ChromaDB
- Embeddings: all-MiniLM-L6-v2 (HuggingFace)
- Parsing: BeautifulSoup4 (Web), PyPDF (Docs)
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.2.0.tar.gz.
File metadata
- Download URL: memloop-0.2.0.tar.gz
- Upload date:
- Size: 16.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 |
0ab06f847214183bd76fac2a59e7f5f77de16602c91e9664fbfc4e22026aabef
|
|
| MD5 |
7fde0d3387c85dd25e035b18c10212cf
|
|
| BLAKE2b-256 |
e2f8a7a3a8b0ac364ef733b2b86c2182ec4898cfa8b5306f7e006b2a6ba61b71
|
File details
Details for the file memloop-0.2.0-py3-none-any.whl.
File metadata
- Download URL: memloop-0.2.0-py3-none-any.whl
- Upload date:
- Size: 16.1 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 |
55704f2155eed2abe769fc0243d7b0e9894aca6d71e4217b1dc4da33ba3b6077
|
|
| MD5 |
50cc9a8263e884cb948c65917ca145be
|
|
| BLAKE2b-256 |
8492bc5482d5db5fd764e8eb290aad2222f979483287787cfaebf61ceae95aae
|