跳到主要内容
版本:V1.1.0

Google Vertex AI

Google Vertex AI 提供多种文本 Embedding 模型。seekdb 提供 GoogleVertexEmbeddingFunction 封装,用于在写入 documents 或使用 query_texts 查询时,自动调用 Vertex AI 生成向量并完成相似性检索。

提示

使用 Google Vertex AI 服务需要遵循 Google Cloud 的收费规则,可能产生相应费用。请在继续前,访问其官网或查阅相关文档,确认并接受其收费标准。如不同意,请勿继续操作。

依赖与鉴权

使用该 Embedding Function 通常需要:

  • 已开通 Google Cloud / Vertex AI,并对目标 Embedding 模型具备调用权限
  • 已配置 Google Application Default Credentials(ADC)

安装

npm i seekdb @seekdb/google-vertex

示例:创建 Google Vertex AI Embedding Function

import { GoogleVertexEmbeddingFunction } from "@seekdb/google-vertex";

const ef = new GoogleVertexEmbeddingFunction({
projectId: "your-gcp-project-id",
modelName: "textembedding-gecko",
});

配置项说明:

  • projectId:Google Cloud 项目 ID(必填)
  • location:Vertex AI 地域(默认:"us-central1"
  • modelName:Embedding 模型名称(默认:"textembedding-gecko"