From e64d48ba0cc79be2dcb44f5f241f7d9a66c5f947 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Thu, 18 Jan 2024 17:42:26 -0800 Subject: [PATCH] Add notifications on sync jobs --- workers/functions/runRAGTest/index.js | 4 ++++ workers/functions/syncChroma/index.js | 14 ++++++++++++++ workers/functions/syncChromaWorkspace/index.js | 13 +++++++++++++ workers/functions/syncPinecone/index.js | 14 ++++++++++++++ workers/functions/syncPineconeWorkspace/index.js | 14 ++++++++++++++ workers/functions/syncQDrantCluster/index.js | 14 ++++++++++++++ workers/functions/syncQDrantWorkspace/index.js | 15 +++++++++++++++ workers/functions/syncWeaviateCluster/index.js | 15 +++++++++++++++ workers/functions/syncWeaviateWorkspace/index.js | 15 +++++++++++++++ 9 files changed, 118 insertions(+) diff --git a/workers/functions/runRAGTest/index.js b/workers/functions/runRAGTest/index.js index 30b114bb..6a50e960 100644 --- a/workers/functions/runRAGTest/index.js +++ b/workers/functions/runRAGTest/index.js @@ -151,6 +151,10 @@ const runRAGTest = InngestClient.createFunction( error: e.message, details: e, }; + await Notification.create(organization.id, { + textContent: 'Your Context Drift test failed to run.', + symbol: Notification.symbols.error, + }); await RagTest.updateRun(run?.id, { status: RagTest.status.failed, results: { diff --git a/workers/functions/syncChroma/index.js b/workers/functions/syncChroma/index.js index 22a9710b..a6d0d7bd 100644 --- a/workers/functions/syncChroma/index.js +++ b/workers/functions/syncChroma/index.js @@ -13,6 +13,7 @@ const { } = require('../../../backend/models/workspaceDocument'); const { DocumentVectors } = require('../../../backend/models/documentVectors'); const { vectorSpaceMetric } = require('../../utils/telemetryHelpers'); +const { Notification } = require('../../../backend/models/notification'); const syncChromaInstance = InngestClient.createFunction( { name: 'Sync Chroma Instance' }, @@ -77,6 +78,13 @@ const syncChromaInstance = InngestClient.createFunction( } of ${collections.length - failedToSync.length} collections.`, failedToSync, }; + + await Notification.create(organization.id, { + textContent: 'Your Chroma instance has been fully synced.', + symbol: Notification.symbols.chroma, + link: `/dashboard/${organization.slug}`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.complete, result); await vectorSpaceMetric(); return { result }; @@ -87,6 +95,12 @@ const syncChromaInstance = InngestClient.createFunction( error: e.message, details: e, }; + await Notification.create(organization.id, { + textContent: 'Your Chroma instance failed to sync.', + symbol: Notification.symbols.error, + link: `/dashboard/${organization.slug}/jobs`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.failed, result); } } diff --git a/workers/functions/syncChromaWorkspace/index.js b/workers/functions/syncChromaWorkspace/index.js index 71963eea..04cccbe6 100644 --- a/workers/functions/syncChromaWorkspace/index.js +++ b/workers/functions/syncChromaWorkspace/index.js @@ -11,6 +11,7 @@ const { const { DocumentVectors } = require('../../../backend/models/documentVectors'); const { deleteVectorCacheFile } = require('../../../backend/utils/storage'); const { vectorSpaceMetric } = require('../../utils/telemetryHelpers'); +const { Notification } = require('../../../backend/models/notification'); const syncChromaWorkspace = InngestClient.createFunction( { name: 'Sync Chroma Workspace' }, @@ -47,6 +48,12 @@ const syncChromaWorkspace = InngestClient.createFunction( message: 'Chroma instance vector data has been synced. Workspaces data synced.', }; + await Notification.create(organization.id, { + textContent: 'Your Chroma workspace has been fully synced.', + symbol: Notification.symbols.chroma, + link: `/dashboard/${organization.slug}/workspace/${workspace.fname}`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.complete, result); await vectorSpaceMetric(); return { result }; @@ -57,6 +64,12 @@ const syncChromaWorkspace = InngestClient.createFunction( error: e.message, details: e, }; + await Notification.create(organization.id, { + textContent: 'Your Chroma workspace failed to sync.', + symbol: Notification.symbols.chroma, + link: `/dashboard/${organization.slug}/jobs`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.failed, result); } } diff --git a/workers/functions/syncPinecone/index.js b/workers/functions/syncPinecone/index.js index 1a1de9a3..4674a1dd 100644 --- a/workers/functions/syncPinecone/index.js +++ b/workers/functions/syncPinecone/index.js @@ -13,6 +13,7 @@ const { } = require('../../../backend/models/workspaceDocument'); const { DocumentVectors } = require('../../../backend/models/documentVectors'); const { vectorSpaceMetric } = require('../../utils/telemetryHelpers'); +const { Notification } = require('../../../backend/models/notification'); const syncPineconeIndex = InngestClient.createFunction( { name: 'Sync Pinecone Instance' }, @@ -84,6 +85,13 @@ const syncPineconeIndex = InngestClient.createFunction( } of ${collections.length - failedToSync.length} namespaces.`, failedToSync, }; + + await Notification.create(organization.id, { + textContent: 'Your Pinecone instance has been fully synced.', + symbol: Notification.symbols.pinecone, + link: `/dashboard/${organization.slug}/workspace/${workspace.fname}`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.complete, result); await vectorSpaceMetric(); return { result }; @@ -94,6 +102,12 @@ const syncPineconeIndex = InngestClient.createFunction( error: e.message, details: e, }; + await Notification.create(organization.id, { + textContent: 'Your Pinecone instance failed to sync.', + symbol: Notification.symbols.pinecone, + link: `/dashboard/${organization.slug}/jobs`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.failed, result); } } diff --git a/workers/functions/syncPineconeWorkspace/index.js b/workers/functions/syncPineconeWorkspace/index.js index 5ee047b6..98ee2e24 100644 --- a/workers/functions/syncPineconeWorkspace/index.js +++ b/workers/functions/syncPineconeWorkspace/index.js @@ -11,6 +11,7 @@ const { const { DocumentVectors } = require('../../../backend/models/documentVectors'); const { deleteVectorCacheFile } = require('../../../backend/utils/storage'); const { vectorSpaceMetric } = require('../../utils/telemetryHelpers'); +const { Notification } = require('../../../backend/models/notification'); // Will sync ENTIRE workspace - from a fresh pull. // Ideally we should only be creating/deleting documents which are not known to the system already. @@ -57,6 +58,13 @@ const syncPineconeWorkspace = InngestClient.createFunction( message: 'Pinecone instance vector data has been synced. Workspace updated.', }; + + await Notification.create(organization.id, { + textContent: 'Your Pinecone namespace has been fully synced.', + symbol: Notification.symbols.pinecone, + link: `/dashboard/${organization.slug}/workspace/${workspace.fname}`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.complete, result); await vectorSpaceMetric(); return { result }; @@ -67,6 +75,12 @@ const syncPineconeWorkspace = InngestClient.createFunction( error: e.message, details: e, }; + await Notification.create(organization.id, { + textContent: 'Your Pinecone namespace failed to sync.', + symbol: Notification.symbols.pinecone, + link: `/dashboard/${organization.slug}/jobs`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.failed, result); } } diff --git a/workers/functions/syncQDrantCluster/index.js b/workers/functions/syncQDrantCluster/index.js index 84c9f882..ec277007 100644 --- a/workers/functions/syncQDrantCluster/index.js +++ b/workers/functions/syncQDrantCluster/index.js @@ -13,6 +13,7 @@ const { QDrant, } = require('../../../backend/utils/vectordatabases/providers/qdrant'); const { vectorSpaceMetric } = require('../../utils/telemetryHelpers'); +const { Notification } = require('../../../backend/models/notification'); const syncQDrantCluster = InngestClient.createFunction( { name: 'Sync Qdrant Instance' }, @@ -77,6 +78,13 @@ const syncQDrantCluster = InngestClient.createFunction( } of ${collections.length - failedToSync.length} collections.`, failedToSync, }; + + await Notification.create(organization.id, { + textContent: 'Your QDrant cluster has been fully synced.', + symbol: Notification.symbols.qdrant, + link: `/dashboard/${organization.slug}/workspace/${workspace.fname}`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.complete, result); await vectorSpaceMetric(); return { result }; @@ -87,6 +95,12 @@ const syncQDrantCluster = InngestClient.createFunction( error: e.message, details: e, }; + await Notification.create(organization.id, { + textContent: 'Your QDrant cluster failed to sync.', + symbol: Notification.symbols.qdrant, + link: `/dashboard/${organization.slug}/jobs`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.failed, result); } } diff --git a/workers/functions/syncQDrantWorkspace/index.js b/workers/functions/syncQDrantWorkspace/index.js index c90b06c7..ec9b4b48 100644 --- a/workers/functions/syncQDrantWorkspace/index.js +++ b/workers/functions/syncQDrantWorkspace/index.js @@ -11,6 +11,7 @@ const { QDrant, } = require('../../../backend/utils/vectordatabases/providers/qdrant'); const { vectorSpaceMetric } = require('../../utils/telemetryHelpers'); +const { Notification } = require('../../../backend/models/notification'); const syncQDrantWorkspace = InngestClient.createFunction( { name: 'Sync QDrant Workspace' }, @@ -51,6 +52,13 @@ const syncQDrantWorkspace = InngestClient.createFunction( message: 'QDrant instance vector data has been synced. Workspaces data synced.', }; + + await Notification.create(organization.id, { + textContent: 'Your QDrant namespace has been fully synced.', + symbol: Notification.symbols.qdrant, + link: `/dashboard/${organization.slug}/workspace/${workspace.fname}`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.complete, result); await vectorSpaceMetric(); return { result }; @@ -61,6 +69,13 @@ const syncQDrantWorkspace = InngestClient.createFunction( error: e.message, details: e, }; + + await Notification.create(organization.id, { + textContent: 'Your QDrant namespace failed to sync.', + symbol: Notification.symbols.qdrant, + link: `/dashboard/${organization.slug}/jobs`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.failed, result); } } diff --git a/workers/functions/syncWeaviateCluster/index.js b/workers/functions/syncWeaviateCluster/index.js index 93d6ea32..ed48b946 100644 --- a/workers/functions/syncWeaviateCluster/index.js +++ b/workers/functions/syncWeaviateCluster/index.js @@ -13,6 +13,7 @@ const { Weaviate, } = require('../../../backend/utils/vectordatabases/providers/weaviate'); const { vectorSpaceMetric } = require('../../utils/telemetryHelpers'); +const { Notification } = require('../../../backend/models/notification'); const syncWeaviateCluster = InngestClient.createFunction( { name: 'Sync Weaviate Instance' }, @@ -77,6 +78,13 @@ const syncWeaviateCluster = InngestClient.createFunction( } of ${collections.length - failedToSync.length} collections.`, failedToSync, }; + + await Notification.create(organization.id, { + textContent: 'Your Weaviate cluster has been fully synced.', + symbol: Notification.symbols.weaviate, + link: `/dashboard/${organization.slug}/workspace/${workspace.fname}`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.complete, result); await vectorSpaceMetric(); return { result }; @@ -87,6 +95,13 @@ const syncWeaviateCluster = InngestClient.createFunction( error: e.message, details: e, }; + + await Notification.create(organization.id, { + textContent: 'Your Weaviate cluster failed to sync.', + symbol: Notification.symbols.weaviate, + link: `/dashboard/${organization.slug}/jobs`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.failed, result); } } diff --git a/workers/functions/syncWeaviateWorkspace/index.js b/workers/functions/syncWeaviateWorkspace/index.js index eda9dc09..bf2de8e9 100644 --- a/workers/functions/syncWeaviateWorkspace/index.js +++ b/workers/functions/syncWeaviateWorkspace/index.js @@ -11,6 +11,7 @@ const { Weaviate, } = require('../../../backend/utils/vectordatabases/providers/weaviate'); const { vectorSpaceMetric } = require('../../utils/telemetryHelpers'); +const { Notification } = require('../../../backend/models/notification'); const syncWeaviateWorkspace = InngestClient.createFunction( { name: 'Sync Weaviate Workspace' }, @@ -56,6 +57,13 @@ const syncWeaviateWorkspace = InngestClient.createFunction( message: 'Weaviate instance vector data has been synced. Workspaces data synced.', }; + + await Notification.create(organization.id, { + textContent: 'Your Weaviate namespace has been fully synced.', + symbol: Notification.symbols.weaviate, + link: `/dashboard/${organization.slug}/workspace/${workspace.fname}`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.complete, result); await vectorSpaceMetric(); return { result }; @@ -66,6 +74,13 @@ const syncWeaviateWorkspace = InngestClient.createFunction( error: e.message, details: e, }; + + await Notification.create(organization.id, { + textContent: 'Your Weaviate namespace failed to sync.', + symbol: Notification.symbols.weaviate, + link: `/dashboard/${organization.slug}/jobs`, + target: '_blank', + }); await Queue.updateJob(jobId, Queue.status.failed, result); } }