跳转到主要内容

Google Cloud Firestore的LangChain集成

项目描述

preview pypi versions

快速入门

为了使用这个库,您首先需要完成以下步骤

  1. 选择或创建一个云平台项目。

  2. 为您的项目启用计费。

  3. 启用Google Cloud Firestore API。

  4. 设置身份验证。

安装

使用pip在virtualenv中安装此库。 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-firestore

Windows

pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install langchain-google-firestore

向量存储使用

使用向量存储来存储嵌入式数据并执行向量搜索。

from langchain_google_firestore import FirestoreVectorStore
from langchain_google_vertexai import VertexAIEmbeddings


embedding = VertexAIEmbeddings(model_name="textembedding-gecko@003")
store = FirestoreVectorStore(
    collection="VectorStore",
    embedding=embedding
)

查看完整的向量存储教程。

文档加载器使用

使用文档加载器将数据作为LangChain Document加载。

from langchain_google_firestore import FirestoreLoader

loader = FirestoreLoader("Collection")
docs = loader.lazy_load()

查看完整的文档加载器教程。

聊天消息历史使用

使用ChatMessageHistory存储消息并向LLMs提供会话历史。

from langchain_google_firestore import FirestoreChatMessageHistory

history = FirestoreChatMessageHistory(
    session_id="my-session-id",
    collection="HistoryMessages"
)

查看完整的聊天消息历史教程。

贡献

欢迎并鼓励对该库的贡献。

有关如何开始的信息,请参阅贡献指南

请注意,该项目以贡献者行为准则发布。通过参与该项目,您同意遵守其条款。更多信息请参阅行为准则

许可证

Apache 2.0 - 更多信息请参阅许可证

免责声明

这不是一个官方支持的Google产品。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

此版本没有可用的源分布文件。有关如何生成分布存档的教程,请参阅生成分布存档

构建分布

langchain_google_firestore-0.4.0-py3-none-any.whl (23.4 kB 查看哈希值)

上传时间: Python 3

由以下机构支持