mirror of
https://github.com/colanode/colanode.git
synced 2025-12-16 11:47:47 +01:00
Check ai enabled before scheduling embeddings
This commit is contained in:
@@ -28,6 +28,10 @@ export const deleteEmbeddingCursor = async (cursorId: string) => {
|
||||
};
|
||||
|
||||
export const scheduleNodeEmbedding = async (node: SelectNode) => {
|
||||
if (!configuration.ai.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.type === 'message') {
|
||||
const attributes = node.attributes as MessageAttributes;
|
||||
if (attributes.subtype === 'question' || attributes.subtype === 'answer') {
|
||||
@@ -54,6 +58,10 @@ export const scheduleNodeEmbedding = async (node: SelectNode) => {
|
||||
};
|
||||
|
||||
export const scheduleDocumentEmbedding = async (documentId: string) => {
|
||||
if (!configuration.ai.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
await jobService.addJob(
|
||||
{
|
||||
type: 'embed_document',
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
Node,
|
||||
NodeAttributes,
|
||||
UpdateNodeMutationData,
|
||||
MessageAttributes,
|
||||
} from '@colanode/core';
|
||||
import { decodeState, YDoc } from '@colanode/crdt';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
|
||||
@@ -40,33 +40,35 @@ class JobService {
|
||||
debug(`Job queue error: ${error}`);
|
||||
});
|
||||
|
||||
this.jobQueue.upsertJobScheduler(
|
||||
'check_node_embeddings',
|
||||
{ pattern: '0 */30 * * * *' },
|
||||
{
|
||||
name: 'check_node_embeddings',
|
||||
data: { type: 'check_node_embeddings' } as JobInput,
|
||||
opts: {
|
||||
backoff: 3,
|
||||
attempts: 5,
|
||||
removeOnFail: 1000,
|
||||
},
|
||||
}
|
||||
);
|
||||
if (configuration.ai.enabled) {
|
||||
this.jobQueue.upsertJobScheduler(
|
||||
'check_node_embeddings',
|
||||
{ pattern: '0 */30 * * * *' },
|
||||
{
|
||||
name: 'check_node_embeddings',
|
||||
data: { type: 'check_node_embeddings' } as JobInput,
|
||||
opts: {
|
||||
backoff: 3,
|
||||
attempts: 5,
|
||||
removeOnFail: 1000,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
this.jobQueue.upsertJobScheduler(
|
||||
'check_document_embeddings',
|
||||
{ pattern: '0 */30 * * * *' },
|
||||
{
|
||||
name: 'check_document_embeddings',
|
||||
data: { type: 'check_document_embeddings' } as JobInput,
|
||||
opts: {
|
||||
backoff: 3,
|
||||
attempts: 5,
|
||||
removeOnFail: 1000,
|
||||
},
|
||||
}
|
||||
);
|
||||
this.jobQueue.upsertJobScheduler(
|
||||
'check_document_embeddings',
|
||||
{ pattern: '0 */30 * * * *' },
|
||||
{
|
||||
name: 'check_document_embeddings',
|
||||
data: { type: 'check_document_embeddings' } as JobInput,
|
||||
opts: {
|
||||
backoff: 3,
|
||||
attempts: 5,
|
||||
removeOnFail: 1000,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public async initWorker() {
|
||||
|
||||
Reference in New Issue
Block a user