Pinecone 플러그인

Pinecone 플러그인은 Pinecone 클라우드 벡터 데이터베이스를 사용하는 색인 생성기 및 검색기 구현을 제공합니다.

설치

npm i --save genkitx-pinecone

구성

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

import { pinecone } from 'genkitx-pinecone';

export default configureGenkit({
  plugins: [
    pinecone([
      {
        indexId: 'bob-facts',
        embedder: textEmbeddingGecko,
      },
    ]),
  ],
  // ...
});

Pinecone 색인 ID와 사용할 임베딩 모델을 지정해야 합니다.

또한 Pinecone API 키로 Genkit를 구성해야 합니다. 여기에는 두 가지 방법이 있습니다.

  • PINECONE_API_KEY 환경 변수를 설정합니다.

  • clientParams 선택적 매개변수에 다음과 같이 지정합니다.

    clientParams: {
      apiKey: ...,
    }
    

    이 매개변수의 값은 Pinecone 클라이언트에 전달되는 PineconeConfiguration 객체이며, 클라이언트에서 지원하는 모든 매개변수를 전달하는 데 사용할 수 있습니다.

사용량

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

import { pineconeRetrieverRef } from 'genkitx-pinecone';
import { pineconeIndexerRef } from 'genkitx-pinecone';

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

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

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

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

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