> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# PGVector 集成

> 使用 LangChain Python 与 PGVector 集成。

本页介绍如何在 LangChain 中使用 Postgres [PGVector](https://github.com/pgvector/pgvector) 生态系统。
内容分为两部分：安装与设置，以及特定 PGVector 包装器的参考。

## 安装

* 使用 `pip install pgvector` 安装 Python 包

## 设置

1. 第一步是创建一个已安装 `pgvector` 扩展的数据库。

   请按照 [PGVector 安装步骤](https://github.com/pgvector/pgvector#installation) 中的说明安装数据库和扩展。Docker 镜像是最简单的入门方式。

## 包装器

### VectorStore

存在一个围绕 Postgres 向量数据库的包装器，允许您将其用作向量存储，
无论是用于语义搜索还是示例选择。

要导入此向量存储：

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_community.vectorstores.pgvector import PGVector
```

### 用法

有关 PGVector 包装器的更详细演练，请参阅[此笔记本](/oss/python/integrations/vectorstores/pgvector)

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档](/use-these-docs)通过 MCP 连接到 Claude、VSCode 等，以获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/providers/pgvector.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
