크로마 플러그인

Chroma 플러그인은 클라이언트/서버 모드에서 Chroma 벡터 데이터베이스를 사용하는 색인 생성기 및 검색기 구현을 제공합니다.

설치

npm i --save genkitx-chromadb

구성

이 플러그인을 사용하려면 configureGenkit()를 호출할 때 지정합니다.

import { chroma } from 'genkitx-chromadb';

export default configureGenkit({
  plugins: [
    chroma([
      {
        collectionName: 'bob_collection',
        embedder: textEmbeddingGecko,
      },
    ]),
  ],
  // ...
});

사용할 크로마 컬렉션과 임베딩 모델을 지정해야 합니다. 또한 다음과 같은 두 가지 선택적 매개변수가 있습니다.

  • clientParams: Genkit 흐름과 동일한 머신에서 Chroma 서버를 실행하지 않거나 인증 옵션을 지정해야 하며 기본 Chroma 서버 구성을 실행하지 않는 경우 Chroma ChromaClientParams 객체를 지정하여 Chroma 클라이언트에 전달할 수 있습니다.

    clientParams: {
      path: "http://192.168.10.42:8000",
    }
    
  • embedderOptions: 이 매개변수를 사용하여 삽입 도구에 옵션을 전달합니다.

    embedderOptions: { taskType: 'RETRIEVAL_DOCUMENT' },
    

사용량

다음과 같이 검색기 및 색인 생성기 참조를 가져옵니다.

import { chromaRetrieverRef } from 'genkitx-chromadb';
import { chromaIndexerRef } from 'genkitx-chromadb';

그런 다음 참조를 retrieve()index()에 전달합니다.

// To use the index you configured when you loaded the plugin:
let docs = await retrieve({ retriever: chromaRetrieverRef, query });

// To specify an index:
export const bobFactsRetriever = chromaRetrieverRef({
  collectionName: 'bob-facts',
});
docs = await retrieve({ retriever: bobFactsRetriever, query });
// To use the index you configured when you loaded the plugin:
await index({ indexer: chromaIndexerRef, documents });

// To specify an index:
export const bobFactsIndexer = chromaIndexerRef({
  collectionName: 'bob-facts',
});
await index({ indexer: bobFactsIndexer, documents });

색인 생성기 및 검색기에 대한 일반적인 설명은 검색 보강 생성 페이지를 참조하세요.