以编程方式使用文档

Gel 是一个建立在 PostgreSQL 之上的强大数据平台。

  • - 以对象和图的方式思考,而非表和 JOIN。
  • - 使用高级 Python SDK、集成 GUI、迁移引擎、Auth 和 AI 层等功能。
  • - 本地运行、远程运行,或在 完全托管的云.

安装

pip install langchain-gel
uv add langchain-gel

设置

  1. 运行 gel project init
  2. 编辑 schema。要使用 LangChain 向量存储,您需要以下类型:
using extension pgvector;

module default {
    scalar type EmbeddingVector extending ext::pgvector::vector<1536>;

    type Record {
        required collection: str;
        text: str;
        embedding: EmbeddingVector;
        external_id: str {
            constraint exclusive;
        };
        metadata: json;

        index ext::pgvector::hnsw_cosine(m := 16, ef_construction := 128)
            on (.embedding)
    }
}

> 注意:这是最小配置。随意添加任意数量的类型、属性和链接! > 通过阅读了解更多利用 Gel schema 的信息 文档.

  1. 运行迁移: gel migration create && gel migrate.

用法

from langchain_gel import GelVectorStore

vector_store = GelVectorStore(
    embeddings=embeddings,
)

查看 完整的 GEL 向量存储使用示例.