mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
cfc225ecb3
**Description:** - Implement `SQLStrStore` and `SQLDocStore` classes that inherits from `BaseStore` to allow to persist data remotely on a SQL server. - SQL is widely used and sometimes we do not want to install a caching solution like Redis. - Multiple issues/comments complain that there is no easy remote and persistent solution that are not in memory (users want to replace InMemoryStore), e.g., https://github.com/langchain-ai/langchain/issues/14267, https://github.com/langchain-ai/langchain/issues/15633, https://github.com/langchain-ai/langchain/issues/14643, https://stackoverflow.com/questions/77385587/persist-parentdocumentretriever-of-langchain - This is particularly painful when wanting to use `ParentDocumentRetriever ` - This implementation is particularly useful when: * it's expensive to construct an InMemoryDocstore/dict * you want to retrieve documents from remote sources * you just want to reuse existing objects - This implementation integrates well with PGVector, indeed, when using PGVector, you already have a SQL instance running. `SQLDocStore` is a convenient way of using this instance to store documents associated to vectors. An integration example with ParentDocumentRetriever and PGVector is provided in docs/docs/integrations/stores/sql.ipynb or [here](https://github.com/gcheron/langchain/blob/sql-store/docs/docs/integrations/stores/sql.ipynb). - It persists `str` and `Document` objects but can be easily extended. **Issue:** Provide an easy SQL alternative to `InMemoryStore`. --------- Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
32 lines
757 B
Python
32 lines
757 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.redis import RedisStore
|
|
from langchain_community.storage.sql import (
|
|
SQLDocStore,
|
|
SQLStrStore,
|
|
)
|
|
from langchain_community.storage.upstash_redis import (
|
|
UpstashRedisByteStore,
|
|
UpstashRedisStore,
|
|
)
|
|
|
|
__all__ = [
|
|
"AstraDBStore",
|
|
"AstraDBByteStore",
|
|
"RedisStore",
|
|
"UpstashRedisByteStore",
|
|
"UpstashRedisStore",
|
|
"SQLDocStore",
|
|
"SQLStrStore",
|
|
]
|