Skip to main content

Mem-LLM 🧠💻

PyPI version Python 3.8+ License: MIT

Mem-LLM is a privacy-first, local Python framework for building memory-enabled AI assistants. By running entirely on your local machine, it combines persistent multi-user conversation history with configurable knowledge bases, robust storage backends, and seamless multi-model support.

Perfect for privacy-first, production-ready workflows!

🔗 Quick Links


What's New in v2.5.1

Dependency fixes. Graph memory needs pydantic and the API server's upload endpoint needs python-multipart; neither was declared, so on a clean install graph memory silently degraded to a no-op and pip install mem-llm[api] could not import the API server. Both are now declared, so a plain pip install mem-llm gets working graph memory.


What's New in v2.5.0

This release expands local backend support and upgrades long-term memory:

  • OpenAI-Compatible Backends: Use any /v1/chat/completions compatible server.
  • llama.cpp Support: Connect directly to llama-server with backend="llamacpp".
  • MemoryRouter: Unified core memory, archival memory, recall, graph context, and KB retrieval.
  • Temporal Graph Memory: Track current facts and historical facts with validity windows.
  • Cleanup: Reduced duplicated backend alias and chat context-building logic.

✨ Core Highlights

  • Persistent Multi-User Memory: Keep context across sessions. Supports lightweight JSON or robust SQLite databases.
  • Advanced Tool Calling: Endow your agent with superpowers! Use built-in tools or easily create your own with the @tool decorator.
  • Multi-Backend Flexible Support: Switch between Ollama, LM Studio, OpenAI-compatible APIs, and llama.cpp.
  • Long-Term Memory Routing: Combine core memory, archival memory, recall, knowledge base, and graph context.
  • Temporal Graph Memory: Preserve changing facts without losing history.
  • Knowledge Base (RAG) & Vector Stores: Empower your agent with your own documents and databases organically.
  • Conversation Analytics: Track interactions, model performance, and agent behavior systematically.
  • REST API + Web UI: Deploy your local agent instantly with the built-in, ready-to-use API server and slick web interface.
  • Real-Time Streaming: Stream chat responses chunk by chunk for ultra-low latency experiences.

📦 Installation

Get up and running in seconds.

pip install mem-llm

Optional Power-ups:

# Add API server dependencies (FastAPI, Uvicorn)
pip install mem-llm[api]

# Add advanced database support
pip install mem-llm[databases]

⚡ Quick Start

Using Ollama 🦙

Make sure your Ollama instance is running, then try this simple example:

from mem_llm import MemAgent

# Initialize the agent
agent = MemAgent(backend="ollama", model="granite4:3b")

# Set the active user (memory will be uniquely tied to this ID)
agent.set_user("alice")

# Chat and watch it remember!
print(agent.chat("Hi! My name is Alice and I am a Software Engineer."))
print(agent.chat("What was my name and what do I do?")) 

Using LM Studio 🛠️

Ensure LM Studio's local server is running on its default port:

from mem_llm import MemAgent

agent = MemAgent(backend="lmstudio", model="qwen3.5-2b")
agent.set_user("bob")

print(agent.chat("Explain Python memory management in 2 sentences."))

Using llama.cpp

Start llama-server with an OpenAI-compatible endpoint:

llama-server.exe -m C:\path\to\model.gguf --alias local-model --host 127.0.0.1 --port 8080

Connect Mem-LLM:

from mem_llm import MemAgent

agent = MemAgent(
    backend="llamacpp",
    model="local-model",
    base_url="http://localhost:8080",
)
agent.set_user("carol")

print(agent.chat("Remember that I prefer concise answers."))

📄 License

Mem-LLM is proudly open-source and released under the MIT License. Build away!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mem_llm-2.5.1.tar.gz (149.0 kB view details)

Uploaded Source

Built Distribution

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

mem_llm-2.5.1-py3-none-any.whl (151.9 kB view details)

Uploaded Python 3

File details

Details for the file mem_llm-2.5.1.tar.gz.

File metadata

  • Download URL: mem_llm-2.5.1.tar.gz
  • Upload date:
  • Size: 149.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for mem_llm-2.5.1.tar.gz
Algorithm Hash digest
SHA256 f593aa61fb10af75a2ad396e7a70855f422accd9cdb020fdd604290af6bfe67a
MD5 6295ec705ac874bdb33c30b396f3805f
BLAKE2b-256 b2f7f53e042cd0a40779258786b80deacf684a390122d778ba187786edd9ddef

See more details on using hashes here.

File details

Details for the file mem_llm-2.5.1-py3-none-any.whl.

File metadata

  • Download URL: mem_llm-2.5.1-py3-none-any.whl
  • Upload date:
  • Size: 151.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for mem_llm-2.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 33c7edc323a2be4a5791167685aaff7a2eccbe40fc97d779df9b650e621f541a
MD5 b0eaa0353de4fb9030fb8021db183519
BLAKE2b-256 c3423629928c7aec841f22f22dd444c312e8688f73d944542a5c872df368824d

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