Skip to content

Commit d48e9e4

Browse files
INTPYTHON-433 LangGraph longterm memory: MongoDBStore (#121)
1 parent 3bd3818 commit d48e9e4

File tree

16 files changed

+4278
-566
lines changed

16 files changed

+4278
-566
lines changed

.github/scripts/check_diff.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
import sys
33
from typing import Dict
44

5-
LIB_DIRS = ["libs/langchain-mongodb", "libs/langgraph-checkpoint-mongodb"]
5+
LIB_DIRS = [
6+
"libs/langchain-mongodb",
7+
"libs/langgraph-checkpoint-mongodb",
8+
"libs/langgraph-store-mongodb",
9+
]
610

711
if __name__ == "__main__":
812
files = sys.argv[1:] # changed files

libs/langgraph-checkpoint-mongodb/pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ readme = "README.md"
1010
requires-python = ">=3.9"
1111
dependencies = [
1212
"langgraph-checkpoint>=2.0.23,<3.0.0",
13+
"langchain-mongodb>=0.6.1",
1314
"pymongo>=4.10,<4.13",
1415
"motor>3.6.0",
1516
]
1617

1718
[dependency-groups]
1819
dev = [
1920
"anyio>=4.4.0",
20-
"langchain-core>=0.3.29",
21+
"langchain-core>=0.3.55",
22+
"langchain-ollama>=0.2.2",
23+
"langchain-openai>=0.2.14",
2124
"langgraph-checkpoint>=2.0.9",
2225
"pytest-asyncio>=0.21.1",
2326
"pytest>=7.2.1",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import os
2+
3+
import pytest
4+
from langchain_core.embeddings import Embeddings
5+
from langchain_ollama.embeddings import OllamaEmbeddings
6+
from langchain_openai import OpenAIEmbeddings
7+
8+
9+
@pytest.fixture(scope="session")
10+
def embedding() -> Embeddings:
11+
if os.environ.get("OPENAI_API_KEY"):
12+
return OpenAIEmbeddings(
13+
openai_api_key=os.environ["OPENAI_API_KEY"], # type: ignore # noqa
14+
model="text-embedding-3-small",
15+
)
16+
17+
return OllamaEmbeddings(model="all-minilm:l6-v2")
18+
19+
20+
@pytest.fixture(scope="session")
21+
def dimensions() -> int:
22+
if os.environ.get("OPENAI_API_KEY"):
23+
return 1536
24+
return 384

libs/langgraph-checkpoint-mongodb/uv.lock

Lines changed: 1372 additions & 563 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
---
4+
5+
## Changes in version 0.0.1 (2025/05/09)
6+
7+
- Initial release, added support for `MongoDBStore`.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# langraph-store-mongodb
2+
3+
LangGraph long-term memory using MongoDB
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
set shell := ["bash", "-c"]
2+
set dotenv-load
3+
set dotenv-filename := "../../.local_atlas_uri"
4+
5+
# Default target executed when no arguments are given.
6+
[private]
7+
default:
8+
@just --list
9+
10+
install:
11+
uv sync --frozen
12+
13+
[group('test')]
14+
integration_tests *args="":
15+
uv run pytest tests/integration_tests/ {{args}}
16+
17+
[group('test')]
18+
unit_tests *args="":
19+
uv run pytest tests/unit_tests {{args}}
20+
21+
[group('test')]
22+
tests *args="":
23+
uv run pytest {{args}}
24+
25+
[group('test')]
26+
test_watch filename:
27+
uv run ptw --snapshot-update --now . -- -vv {{filename}}
28+
29+
[group('lint')]
30+
lint:
31+
git ls-files -- '*.py' | xargs uv run pre-commit run ruff --files
32+
git ls-files -- '*.py' | xargs uv run pre-commit run ruff-format --files
33+
34+
[group('lint')]
35+
typing:
36+
uv run mypy .
37+
38+
[group('lint')]
39+
codespell:
40+
git ls-files -- '*.py' | xargs uv run pre-commit run --hook-stage manual codespell --files
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from .base import (
2+
MongoDBStore,
3+
VectorIndexConfig,
4+
create_vector_index_config,
5+
)
6+
7+
__all__ = ["MongoDBStore", "VectorIndexConfig", "create_vector_index_config"]

0 commit comments

Comments
 (0)