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 इंडेक्स आईडी और इस्तेमाल करने के लिए एम्बेड किया गया मॉडल बताना होगा.

इसके अलावा, आपको Genkit को Pinecone API कुंजी के साथ कॉन्फ़िगर करना होगा. ऐसा करने के दो तरीके हैं:

  • 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 });

इंडेक्सर और रिट्रीवर पर सामान्य चर्चा के लिए, Retrieval-augmented जनरेशन पेज देखें.