Skip to main content

Add your description here

Project description

LangMem0

Python Version Version Lint with Ruff

Environment

  • uv >= 0.9

Quickstart

1. Clone the repository

git clone https://github.com/sammyne/langmem0.git
cd langmem0

2. Install dependencies

uv pip install -e .

3. Set up environment variables

Create a .env file in the project root with your OpenAI configuration:

OPENAI_API_KEY=your_api_key_here
OPENAI_API_BASE_URL=https://api.openai.com/v1
OPENAI_MODEL=gpt-4o-mini

4. Run examples

LangMem0 provides two main ways to integrate memory into your LangChain applications:

Middleware Examples

Use Mem0Middleware to enable memory in LangChain agent conversations. This approach provides fine-grained control over memory operations.

# Synchronous example
uv run examples/middleware/helloworld.py
# Asynchronous example
uv run examples/middleware/helloworld_async.py

These examples demonstrate:

  • Using Mem0Middleware to intercept and augment agent messages with memories
  • How agents can remember and retrieve information across conversations
  • Different thread contexts for separate conversation memories
  • Integration with LangGraph checkpoints

Chat Examples

Use ChatOpenAI with built-in Mem0 memory capabilities for a simpler integration path.

# Basic synchronous example
uv run examples/chat/helloworld.py

# Basic asynchronous example
uv run examples/chat/helloworld_async.py

# Advanced synchronous with RunnableConfig:**
uv run examples/chat/runnable_config.py

# Advanced asynchronous with RunnableConfig:**
uv run examples/chat/runnable_config_async.py

These examples demonstrate:

  • Direct integration with OpenAI-compatible chat models
  • Memory-enabled conversations with minimal setup
  • Using RunnableConfig for thread management
  • Both sync and async API patterns

FAQ

Why not provide tool-based API like langmem

Tool-based API has a problem: system prompt needs augumenting with memories using a separate middleware as demonstrated by LangMem's Hot Path Quickstart.

References

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

langmem0-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

langmem0-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file langmem0-0.1.0.tar.gz.

File metadata

  • Download URL: langmem0-0.1.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langmem0-0.1.0.tar.gz
Algorithm Hash digest
SHA256 182a2dfee666c1ce363967db13c99aa20d8fd673d739d46c0701b5a86a8942bc
MD5 b2ba688aa3061768bc4fa4221618315e
BLAKE2b-256 536925197525aca0f7609c0779fa12271c2e7414346e3a2ea281483293c7ba7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for langmem0-0.1.0.tar.gz:

Publisher: pypi.yml on sammyne/langmem0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langmem0-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: langmem0-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langmem0-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b9f1c66e9f712fc56eb994738a217cdfdfa3cb856a23ee06c05d82e7ffddd0f
MD5 1d92151bf57338f9a65fa1ef0250c271
BLAKE2b-256 ff19e090301917cc8ab4c2e49915213c4b4b457ef99869a3f05cf7e9e4d9f834

See more details on using hashes here.

Provenance

The following attestation bundles were made for langmem0-0.1.0-py3-none-any.whl:

Publisher: pypi.yml on sammyne/langmem0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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