migration patch

This commit is contained in:
timothycarambat
2023-10-13 12:19:03 -07:00
parent 5f0e392afb
commit b5b3fdc67e
+41 -2
View File
@@ -58,8 +58,8 @@ const migrateOrganization = InngestClient.createFunction(
await Queue.updateJob(jobId, Queue.status.pending, {
message: `Working on namespace ${count} of ${workspaces.length}`,
});
const existsInDestination = await destinationVectorDb.namespaceExists(
null,
const existsInDestination = await namespaceExists(
destinationVectorDb,
workspace.fname
);
if (existsInDestination) {
@@ -185,6 +185,45 @@ const migrateOrganization = InngestClient.createFunction(
}
);
async function namespaceExists(vectorDBClient, namespace) {
if (vectorDBClient.name === 'pinecone') {
try {
const { pineconeIndex } = await vectorDBClient.connect();
return await vectorDBClient.namespaceExists(pineconeIndex, namespace);
} catch (e) {
return null;
}
}
if (vectorDBClient.name === 'chroma') {
try {
return await vectorDBClient.namespaceExists(null, namespace);
} catch (e) {
return null;
}
}
if (vectorDBClient.name === 'qdrant') {
try {
const { client } = await vectorDBClient.connect();
return await vectorDBClient.namespaceExists(client, namespace);
} catch (e) {
return null;
}
}
if (vectorDBClient.name === 'weaviate') {
try {
const className = vectorDBClient.camelCase(namespace);
return await vectorDBClient.namespaceExists(null, className);
} catch (e) {
return null;
}
}
return null;
}
async function createVectorSpace(vectorDBClient, namespace) {
if (vectorDBClient.name === 'chroma') {
try {