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 を構成する必要があります。2 つのモデル 方法:
PINECONE_API_KEY
環境変数を設定する。これは、
clientParams
オプション パラメータで指定します。clientParams: { apiKey: ..., }
このパラメータの値は
PineconeConfiguration
オブジェクトで、 Pinecone クライアントに渡されます。これを使用して任意のパラメータをクライアント サポートします。
用途
リトリーバーとインデクサの参照は、次のようにインポートします。
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 });
一般的な言語については、検索拡張生成のページをご覧ください。 インデクサとリトリーバーに関するディスカッションです。