Google Cloud Memorystore的LangChain集成
项目描述
快速入门
为了使用此库,您首先需要完成以下步骤
安装
使用pip在此虚拟环境中安装此库。 virtualenv 是一种创建隔离Python环境的工具。它解决的基本问题是依赖关系和版本,以及间接的权限。
使用virtualenv,可以安装此库而无需系统安装权限,也不会与已安装的系统依赖冲突。
支持的Python版本
Python >= 3.8
Mac/Linux
pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install langchain-google-memorystore-redis
Windows
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install langchain-google-memorystore-redis
向量存储使用
使用向量存储来存储嵌入数据并执行向量搜索。
from langchain_google_memorystore_redis import RedisVectorStore
redis_client = redis.from_url("redis://127.0.0.1:6379")
embeddings_service = VertexAIEmbeddings(model_name="textembedding-gecko@003")
vectorstore = RedisVectorStore(
client=redis_client,
index_name="my_vector_index",
embeddings=embeddings_service
)
查看完整的向量存储教程。
文档加载器使用
使用文档加载器将数据加载为LangChain Document。
from langchain_google_memorystore_redis import MemorystoreDocumentLoader
loader = MemorystoreDocumentLoader(
client=redis_client,
key_prefix="docs:",
content_fields=set(["page_content"]),
)
docs = loader.lazy_load()
查看完整的文档加载器教程。
聊天消息历史使用
使用 ChatMessageHistory 存储消息,并为 LLMs 提供对话历史。
from langchain_google_memorystore_redis import MemorystoreChatMessageHistory
history = MemorystoreChatMessageHistory(
client=redis_client,
session_id="my-session_id"
)
查看完整的 Chat Message History 教程。
贡献
欢迎并强烈鼓励对该库的贡献。
有关如何开始的更多信息,请参阅 CONTRIBUTING。
请注意,该项目以贡献者行为准则发布。通过参与此项目,您同意遵守其条款。有关更多信息,请参阅 行为准则。
许可证
Apache 2.0 - 有关更多信息,请参阅 LICENSE。
免责声明
这不是官方支持的 Google 产品。
项目详情
关闭
langchain_google_memorystore_redis-0.2.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 7bb23adc21c5a19caf9943e3d2d7a7b877b21b89661db7d96f890cbd462c908b |
|
MD5 | 8e76402238982f4c8099111d294ca709 |
|
BLAKE2b-256 | 2040cc44cfdb2f1d7da6fc5f5a6856440853fa7d30e33c06a738f082cf1a0a1a |