Skip to content

Commit 9a2697a

Browse files
committed
feat: Add support for pinecone index host url
1 parent c9ea982 commit 9a2697a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

js/plugins/pinecone/src/index.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export const pineconeIndexerRef = (params: {
111111
PINECONE_API_KEY. If not set, the PINECONE_API_KEY environment variable will
112112
be used instead.
113113
* @param params.indexId The name of the index
114+
* @param params.indexHostUrl The host url for the index. If not set, only indexId will be used to target the index
114115
* @param params.embedder The embedder to use for the indexer and retriever
115116
* @param params.embedderOptions Options to customize the embedder
116117
* @returns The Pinecone Genkit plugin
@@ -119,6 +120,7 @@ export function pinecone<EmbedderCustomOptions extends z.ZodTypeAny>(
119120
params: {
120121
clientParams?: PineconeConfiguration;
121122
indexId: string;
123+
indexHostUrl?: string;
122124
contentKey?: string;
123125
embedder: EmbedderArgument<EmbedderCustomOptions>;
124126
embedderOptions?: z.infer<EmbedderCustomOptions>;
@@ -137,6 +139,7 @@ export default pinecone;
137139
* @param ai A Genkit instance
138140
* @param params The params for the retriever
139141
* @param params.indexId The name of the retriever
142+
* @param params.indexHostUrl The host url for the index. If not set, only the indexId will be used to target the index
140143
* @param params.clientParams PineconeConfiguration containing the
141144
PINECONE_API_KEY. If not set, the PINECONE_API_KEY environment variable will
142145
be used instead.
@@ -153,6 +156,7 @@ export function configurePineconeRetriever<
153156
ai: Genkit,
154157
params: {
155158
indexId: string;
159+
indexHostUrl?: string;
156160
clientParams?: PineconeConfiguration;
157161
/**
158162
* @deprecated use contentKey instead.
@@ -163,13 +167,13 @@ export function configurePineconeRetriever<
163167
embedderOptions?: z.infer<EmbedderCustomOptions>;
164168
}
165169
) {
166-
const { indexId, embedder, embedderOptions } = {
170+
const { indexId, indexHostUrl, embedder, embedderOptions } = {
167171
...params,
168172
};
169173
const pineconeConfig = params.clientParams ?? getDefaultConfig();
170174
const contentKey = params.contentKey ?? params.textKey ?? CONTENT_KEY;
171175
const pinecone = new Pinecone(pineconeConfig);
172-
const index = pinecone.index(indexId);
176+
const index = pinecone.index(indexId, indexHostUrl);
173177

174178
return ai.defineRetriever(
175179
{
@@ -216,6 +220,7 @@ export function configurePineconeRetriever<
216220
* @param ai A Genkit instance
217221
* @param params The params for the indexer
218222
* @param params.indexId The name of the indexer
223+
* @param params.indexHostUrl The host url for the index. If not set, only the indexId will be used to target the index
219224
* @param params.clientParams PineconeConfiguration containing the
220225
PINECONE_API_KEY. If not set, the PINECONE_API_KEY environment variable will
221226
be used instead.
@@ -232,6 +237,7 @@ export function configurePineconeIndexer<
232237
ai: Genkit,
233238
params: {
234239
indexId: string;
240+
indexHostUrl?: string;
235241
clientParams?: PineconeConfiguration;
236242
/**
237243
* @deprecated use contentKey instead.
@@ -242,13 +248,13 @@ export function configurePineconeIndexer<
242248
embedderOptions?: z.infer<EmbedderCustomOptions>;
243249
}
244250
) {
245-
const { indexId, embedder, embedderOptions } = {
251+
const { indexId, indexHostUrl, embedder, embedderOptions } = {
246252
...params,
247253
};
248254
const pineconeConfig = params.clientParams ?? getDefaultConfig();
249255
const contentKey = params.contentKey ?? params.textKey ?? CONTENT_KEY;
250256
const pinecone = new Pinecone(pineconeConfig);
251-
const index = pinecone.index(indexId);
257+
const index = pinecone.index(indexId, indexHostUrl);
252258

253259
return ai.defineIndexer(
254260
{

0 commit comments

Comments
 (0)