You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create an index using the NodeJS sdk but I'm getting the following error. Initially i was trying to create it using a json file uploaded to cloud storage seting the uri in contentsDeltaUri but same happens when I try to create it empty. What am I doing wrong?
This is the smaller snippet to replicate the error
async function main(
project = 'PROYECT_NAME',
apiEndpoint = 'us-central1-aiplatform.googleapis.com',
) {
const aiplatform = require('@google-cloud/aiplatform');
const {IndexServiceClient} = aiplatform.v1;
const clientOptions = {apiEndpoint: apiEndpoint};
const location = 'us-central1';
async function createIndex(indexName, embeddings) {
const indexClient = new IndexServiceClient(clientOptions);
const parent = `projects/${project}/locations/${location}`;
const index = {
displayName: indexName,
description: 'An index created for storing embeddings',
metadata: {
config: {
dimensions: embeddings[0].embedding.length,
approximateNeighborsCount: 1000,
distanceMeasureType: 'DOT_PRODUCT_DISTANCE'
}
}
};
const request = {
parent,
index
};
const [operation] = await indexClient.createIndex(request);
const [response] = await operation.promise();
console.log('Index created successfully:', response.name);
return response.name;
}
const indexName = 'test-index';
// this is just an example but is not used (only for setting the dimensions of the index)
const embeddings = [
{ id: "0", embedding: [0.027309643104672432, -0.0033781714737415314, 0.011493228375911713] },
{ id: "1", embedding: [0.01877667009830475, -0.07062038034200668, -0.044831905514001846] },
{ id: "2", embedding: [0.034117065370082855, -0.01877667009830475, -0.07062038034200668] }
];
console.log(`Creating index "${indexName}" ...`);
const indexId = await createIndex(indexName, embeddings);
console.log('Created index with ID:', indexId);
}
main()
callstack
Uncaught Error Error: 9 FAILED_PRECONDITION: dimensions is required but missing from Index metadata.
at callErrorFromStatus (d:\Git\spike-gcp\node_modules\@grpc\grpc-js\build\src\call.js:33:26)
at onReceiveStatus (d:\Git\spike-gcp\node_modules\@grpc\grpc-js\build\src\client.js:193:76)
at onReceiveStatus (d:\Git\spike-gcp\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:360:141)
at onReceiveStatus (d:\Git\spike-gcp\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:323:181)
at <anonymous> (d:\Git\spike-gcp\node_modules\@grpc\grpc-js\build\src\resolving-call.js:129:78)
at processTicksAndRejections (<node_internals>/internal/process/task_queues:77:11)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to create an index using the NodeJS sdk but I'm getting the following error. Initially i was trying to create it using a json file uploaded to cloud storage seting the uri in
contentsDeltaUri
but same happens when I try to create it empty. What am I doing wrong?This is the smaller snippet to replicate the error
callstack
Beta Was this translation helpful? Give feedback.
All reactions