@chroma-core/google-gemini

中文文档
0.1.10发布于 2026/03/10TypeScriptESM + CJS近 30 天下载 2.1万

Google Gemini embedding provider for Chroma

原始使用文档
文档目录5 节
  1. Installation
  2. Usage
  3. Configuration
  4. Configuration Options
  5. Supported Models

Google Gemini Embedding Function for Chroma

This package provides a Google Gemini embedding provider for Chroma using the Google Generative AI SDK.

Installation

npm install @chroma-core/google-gemini

Usage

import { ChromaClient } from 'chromadb';
import { GoogleGeminiEmbeddingFunction } from '@chroma-core/google-gemini';

// Initialize the embedder
const embedder = new GoogleGeminiEmbeddingFunction({
  apiKey: 'your-api-key', // Or set GEMINI_API_KEY env var
  modelName: 'text-embedding-004', // Optional, defaults to latest model
  taskType: 'RETRIEVAL_DOCUMENT', // Optional
});

// Create a new ChromaClient
const client = new ChromaClient({
  path: 'http://localhost:8000',
});

// Create a collection with the embedder
const collection = await client.createCollection({
  name: 'my-collection',
  embeddingFunction: embedder,
});

// Add documents
await collection.add({
  ids: ["1", "2", "3"],
  documents: ["Document 1", "Document 2", "Document 3"],
});

// Query documents
const results = await collection.query({
  queryTexts: ["Sample query"],
  nResults: 2,
});

Configuration

Set your Google AI API key as an environment variable:

export GEMINI_API_KEY=your-api-key

Get your API key from the Google AI Studio.

Configuration Options

  • apiKey: Your Google AI API key (or set via environment variable)
  • apiKeyEnvVar: Environment variable name for API key (default: GEMINI_API_KEY)
  • modelName: Model to use for embeddings
  • taskType: Task type for the embedding request (e.g., RETRIEVAL_DOCUMENT, RETRIEVAL_QUERY)

Supported Models

  • text-embedding-004 (latest)
  • embedding-001

Check the Google AI documentation for the most up-to-date list of available embedding models.

版本与发布记录

@chroma-core/google-gemini 共发布 6 个版本,首次发布于 2025/05/21;过去 12 个月发布了 3 个版本。

版本发布日期距今
0.1.10latest2026/03/108 个月前
0.1.92026/03/108 个月前
0.1.82025/11/1311 个月前
0.1.72025/06/051.4 年前
0.1.52025/05/221.5 年前
0.1.02025/05/211.5 年前

关于 @chroma-core/google-gemini 的常见问题

@chroma-core/google-gemini 是什么?

Google Gemini embedding provider for Chroma

如何安装 @chroma-core/google-gemini?

在项目目录运行 npm install @chroma-core/google-gemini,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:chromadb(^3.3.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@chroma-core/google-gemini 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@chroma-core/google-gemini 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@chroma-core/google-gemini 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@chroma-core/google-gemini 可以商用吗?

@chroma-core/google-gemini 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@chroma-core/google-gemini 的下载量有多少?

根据 npm 官方下载统计,@chroma-core/google-gemini 在 2026/10/10 – 2026/11/08 这 30 天内被下载 20,991 次,日均约 700 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@chroma-core/google-gemini 还在维护吗?

最新版本 0.1.10 发布于 2026/03/10(8 个月前);至今共发布 6 个版本,其中过去 12 个月发布了 3 个;首次发布于 2025/05/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。