Skip to main content
turbopuffer is a fast, cost-efficient vector database for search and retrieval.
This guide shows how to use the TurbopufferVectorStore with LangChain.

设置

To use the turbopuffer vector store, you need to install the langchain-turbopuffer integration package.

凭证

Create a turbopuffer account at turbopuffer.com and get an API key.
If you want to get automated tracing of your model calls you can also set your LangSmith API key by uncommenting below:

初始化

Create a turbopuffer client and namespace, then initialize the vector store:

管理向量存储

Once you have created your vector store, you can interact with it by adding and deleting items.

向向量存储添加项目

从向量存储删除项目

查询向量存储

一旦创建了向量存储并添加了相关文档,您很可能希望在链或智能体运行期间对其进行查询。

直接查询

可以按以下方式执行简单的相似度搜索:

带分数的相似度搜索

You can also search with score. Lower distance means more similar:

转换为检索器进行查询

您还可以将向量存储转换为检索器,以便在链中更方便地使用。

过滤

turbopuffer supports metadata filtering using tuple expressions. Pass filters to any search method:
See the turbopuffer filter documentation for the full list of supported filter operators.