Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for pinecone index host url #2182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions js/plugins/pinecone/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const pineconeIndexerRef = (params: {
PINECONE_API_KEY. If not set, the PINECONE_API_KEY environment variable will
be used instead.
* @param params.indexId The name of the index
* @param params.indexHostUrl The host url for the index. If not set, only indexId will be used to target the index
* @param params.embedder The embedder to use for the indexer and retriever
* @param params.embedderOptions Options to customize the embedder
* @returns The Pinecone Genkit plugin
Expand All @@ -119,6 +120,7 @@ export function pinecone<EmbedderCustomOptions extends z.ZodTypeAny>(
params: {
clientParams?: PineconeConfiguration;
indexId: string;
indexHostUrl?: string;
contentKey?: string;
embedder: EmbedderArgument<EmbedderCustomOptions>;
embedderOptions?: z.infer<EmbedderCustomOptions>;
Expand All @@ -137,6 +139,7 @@ export default pinecone;
* @param ai A Genkit instance
* @param params The params for the retriever
* @param params.indexId The name of the retriever
* @param params.indexHostUrl The host url for the index. If not set, only the indexId will be used to target the index
* @param params.clientParams PineconeConfiguration containing the
PINECONE_API_KEY. If not set, the PINECONE_API_KEY environment variable will
be used instead.
Expand All @@ -153,6 +156,7 @@ export function configurePineconeRetriever<
ai: Genkit,
params: {
indexId: string;
indexHostUrl?: string;
clientParams?: PineconeConfiguration;
/**
* @deprecated use contentKey instead.
Expand All @@ -163,13 +167,13 @@ export function configurePineconeRetriever<
embedderOptions?: z.infer<EmbedderCustomOptions>;
}
) {
const { indexId, embedder, embedderOptions } = {
const { indexId, indexHostUrl, embedder, embedderOptions } = {
...params,
};
const pineconeConfig = params.clientParams ?? getDefaultConfig();
const contentKey = params.contentKey ?? params.textKey ?? CONTENT_KEY;
const pinecone = new Pinecone(pineconeConfig);
const index = pinecone.index(indexId);
const index = pinecone.index(indexId, indexHostUrl);

return ai.defineRetriever(
{
Expand Down Expand Up @@ -216,6 +220,7 @@ export function configurePineconeRetriever<
* @param ai A Genkit instance
* @param params The params for the indexer
* @param params.indexId The name of the indexer
* @param params.indexHostUrl The host url for the index. If not set, only the indexId will be used to target the index
* @param params.clientParams PineconeConfiguration containing the
PINECONE_API_KEY. If not set, the PINECONE_API_KEY environment variable will
be used instead.
Expand All @@ -232,6 +237,7 @@ export function configurePineconeIndexer<
ai: Genkit,
params: {
indexId: string;
indexHostUrl?: string;
clientParams?: PineconeConfiguration;
/**
* @deprecated use contentKey instead.
Expand All @@ -242,13 +248,13 @@ export function configurePineconeIndexer<
embedderOptions?: z.infer<EmbedderCustomOptions>;
}
) {
const { indexId, embedder, embedderOptions } = {
const { indexId, indexHostUrl, embedder, embedderOptions } = {
...params,
};
const pineconeConfig = params.clientParams ?? getDefaultConfig();
const contentKey = params.contentKey ?? params.textKey ?? CONTENT_KEY;
const pinecone = new Pinecone(pineconeConfig);
const index = pinecone.index(indexId);
const index = pinecone.index(indexId, indexHostUrl);

return ai.defineIndexer(
{
Expand Down