Skip to main content

MongoDB implementation of the LangGraph long-term memory store.

Project description

langraph-store-mongodb

LangGraph long-term memory using MongoDB.

Installation

pip install -U langgraph-store-mongodb

Usage

For more detailed usage examples and documentation, please refer to the MongoDB LangGraph documentation.

from langgraph.store.mongodb import MongoDBStore, create_vector_index_config
from langchain_voyageai import VoyageAIEmbeddings

# Vector search index configuration with client-side embedding
index_config = create_vector_index_config(
    embed = VoyageAIEmbeddings(),
    dims = <dimensions>,
    fields = ["<field-name>"],
    filters = ["<filter-field-name>", ...] # Optional
)

# Store memories in MongoDB collection
with MongoDBStore.from_conn_string(
     conn_string=MONGODB_URI,
     db_name="<database-name>",
     collection_name="<collection-name>",
     index_config=index_config
 ) as store:
     store.put(
         namespace=("user", "memories"),
         key=f"memory_{hash(content)}",
         value={"content": content}
     )

# Retrieve memories from MongoDB collection
with MongoDBStore.from_conn_string(
    conn_string=MONGODB_URI,
    db_name="<database-name>",
    collection_name="<collection-name>",
    index_config=index_config
) as store:
     results = store.search(
         ("user", "memories"),
         query="<query-text>",
         limit=3
     )
     for result in results:
         print(result.value)

# To delete memories, use store.delete(namespace, key)
# To batch operations, use store.batch(ops)

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

langgraph_store_mongodb-0.3.0.tar.gz (110.5 kB view details)

Uploaded Source

Built Distribution

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

langgraph_store_mongodb-0.3.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file langgraph_store_mongodb-0.3.0.tar.gz.

File metadata

  • Download URL: langgraph_store_mongodb-0.3.0.tar.gz
  • Upload date:
  • Size: 110.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for langgraph_store_mongodb-0.3.0.tar.gz
Algorithm Hash digest
SHA256 87d1e809f3b317c55c3106c30922246c1336c335d7ebc37d670e00f810c03ae5
MD5 84160c872863bdc0d5d38894c83d78fa
BLAKE2b-256 2b5d75fe61110b2644355d21bd85a6b12498ca49bb18be858e4aacd6aa95c917

See more details on using hashes here.

File details

Details for the file langgraph_store_mongodb-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langgraph_store_mongodb-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3629892932362d7f43e53bcd0e8ae9bbea01a558fd92a2d5e960c039ff54e65f
MD5 e7e1658f17b3b1731aa2fb8b44e4fd5e
BLAKE2b-256 3e8ce803901b5bb366ed7366b270c8c1b01a294b020297fff818a0de79f00f01

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