mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
5738143d4b
# Add MongoDB storage - **Description:** Add MongoDB Storage as an option for large doc store. Example usage: ```Python # Instantiate the MongodbStore with a MongoDB connection from langchain.storage import MongodbStore mongo_conn_str = "mongodb://localhost:27017/" mongodb_store = MongodbStore(mongo_conn_str, db_name="test-db", collection_name="test-collection") # Set values for keys doc1 = Document(page_content='test1') doc2 = Document(page_content='test2') mongodb_store.mset([("key1", doc1), ("key2", doc2)]) # Get values for keys values = mongodb_store.mget(["key1", "key2"]) # [doc1, doc2] # Iterate over keys for key in mongodb_store.yield_keys(): print(key) # Delete keys mongodb_store.mdelete(["key1", "key2"]) ``` - **Dependencies:** Use `mongomock` for integration test. --------- Co-authored-by: Bagatur <baskaryan@gmail.com> Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
28 lines
718 B
Python
28 lines
718 B
Python
"""Implementations of key-value stores and storage helpers.
|
|
|
|
Module provides implementations of various key-value stores that conform
|
|
to a simple key-value interface.
|
|
|
|
The primary goal of these storages is to support implementation of caching.
|
|
"""
|
|
|
|
from langchain_community.storage.astradb import (
|
|
AstraDBByteStore,
|
|
AstraDBStore,
|
|
)
|
|
from langchain_community.storage.mongodb import MongoDBStore
|
|
from langchain_community.storage.redis import RedisStore
|
|
from langchain_community.storage.upstash_redis import (
|
|
UpstashRedisByteStore,
|
|
UpstashRedisStore,
|
|
)
|
|
|
|
__all__ = [
|
|
"AstraDBStore",
|
|
"AstraDBByteStore",
|
|
"MongoDBStore",
|
|
"RedisStore",
|
|
"UpstashRedisByteStore",
|
|
"UpstashRedisStore",
|
|
]
|