genkitx-milvus
Firebase Genkit - Milvus Plugin
Milvus Community Plugin for Google Firebase Genkit
genkitx-milvus
is a community plugin for using Milvus Vector Database with
Firebase Genkit. Built by Bloom Labs Inc. π₯
Installationβ
Install the plugin in your project with your favorite package manager:
npm install genkitx-milvus
yarn add genkitx-milvus
pnpm add genkitx-milvus
Usageβ
Initializeβ
To use this plugin, specify it when you initialize Genkit:
import { genkit } from 'genkit';
import { milvus } from 'genkitx-milvus';
export default genkit({
plugins: [
milvus([
{
collectionName: 'collection_01',
embedder: textEmbeddingGecko,
},
]),
],
// ...
});
You must specify a Milvus collection and the embedding model youΒ want to use. In addition, there are three optional parameters:
-
dbName
: Specified database -
clientParams
: If you're not running your Milvus server on the same machine as your Genkit flow, you need to specify auth options, or you're otherwise not running a default Milvus server configuration, you can specify Milvus client connection parameters: address and token.clientParams: {
address: "",
token: "",
} -
embedderOptions
: Use this parameter to pass options to the embedder:embedderOptions: { taskType: 'RETRIEVAL_DOCUMENT' },
Basic Examplesβ
Import retriever and indexer references like so:
import { milvusRetrieverRef, milvusIndexerRef } from 'genkitx-milvus';
Then, use the references with ai.retrieve()
and ai.index()
:
// To use the index you configured when you loaded the plugin:
let docs = await ai.retrieve({ retriever: milvusRetrieverRef, query });
// To specify an index:
export const customRetriever = milvusRetrieverRef({
collectionName: 'collection_01',
});
docs = await ai.retrieve({ retriever: customRetriever, query });
// To use the index you configured when you loaded the plugin:
await ai.index({ indexer: milvusIndexerRef, documents });
// To specify an index:
export const customIndexer = milvusIndexerRef({
collectionName: 'collection_01',
});
await ai.index({ indexer: customIndexer, documents });
Contributingβ
Want to contribute to the project? That's awesome! Head over to our Contribution Guidelines.