mirror of
https://github.com/docmost/docmost.git
synced 2025-11-10 08:42:05 +10:00
refine
This commit is contained in:
@ -50,6 +50,7 @@ export class WorkspaceService {
|
|||||||
@InjectKysely() private readonly db: KyselyDB,
|
@InjectKysely() private readonly db: KyselyDB,
|
||||||
@InjectQueue(QueueName.ATTACHMENT_QUEUE) private attachmentQueue: Queue,
|
@InjectQueue(QueueName.ATTACHMENT_QUEUE) private attachmentQueue: Queue,
|
||||||
@InjectQueue(QueueName.BILLING_QUEUE) private billingQueue: Queue,
|
@InjectQueue(QueueName.BILLING_QUEUE) private billingQueue: Queue,
|
||||||
|
@InjectQueue(QueueName.AI_QUEUE) private aiQueue: Queue,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async findById(workspaceId: string) {
|
async findById(workspaceId: string) {
|
||||||
@ -315,22 +316,36 @@ export class WorkspaceService {
|
|||||||
if (typeof updateWorkspaceDto.aiSearch !== 'undefined') {
|
if (typeof updateWorkspaceDto.aiSearch !== 'undefined') {
|
||||||
await this.workspaceRepo.updateAiSettings(
|
await this.workspaceRepo.updateAiSettings(
|
||||||
workspaceId,
|
workspaceId,
|
||||||
'aiSearch',
|
'search',
|
||||||
updateWorkspaceDto.aiSearch,
|
updateWorkspaceDto.aiSearch,
|
||||||
);
|
);
|
||||||
|
|
||||||
// to enable this
|
if (updateWorkspaceDto.aiSearch) {
|
||||||
// we need to check if pgvector and embeddings table exists
|
await this.aiQueue.add(QueueJob.WORKSPACE_CREATE_EMBEDDINGS, {
|
||||||
|
workspaceId,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Schedule deletion after 24 hours
|
||||||
|
const deleteJobId = `ai-search-disabled-${workspaceId}`;
|
||||||
|
await this.aiQueue.add(
|
||||||
|
QueueJob.WORKSPACE_DELETE_EMBEDDINGS,
|
||||||
|
{ workspaceId },
|
||||||
|
{
|
||||||
|
jobId: deleteJobId,
|
||||||
|
delay: 24 * 60 * 60 * 1000,
|
||||||
|
removeOnComplete: true,
|
||||||
|
removeOnFail: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
delete updateWorkspaceDto.aiSearch;
|
delete updateWorkspaceDto.aiSearch;
|
||||||
// if true, send to ai queue
|
|
||||||
// if false, send to delete embeddings
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof updateWorkspaceDto.generativeAi !== 'undefined') {
|
if (typeof updateWorkspaceDto.generativeAi !== 'undefined') {
|
||||||
await this.workspaceRepo.updateAiSettings(
|
await this.workspaceRepo.updateAiSettings(
|
||||||
workspaceId,
|
workspaceId,
|
||||||
'generativeAi',
|
'generative',
|
||||||
updateWorkspaceDto.generativeAi,
|
updateWorkspaceDto.generativeAi,
|
||||||
);
|
);
|
||||||
delete updateWorkspaceDto.generativeAi;
|
delete updateWorkspaceDto.generativeAi;
|
||||||
|
|||||||
Submodule apps/server/src/ee updated: f7ff3ff80d...4de95306c7
@ -53,6 +53,7 @@ export enum QueueJob {
|
|||||||
WORKSPACE_CREATED = 'workspace-created',
|
WORKSPACE_CREATED = 'workspace-created',
|
||||||
WORKSPACE_SPACE_UPDATED = 'workspace-updated',
|
WORKSPACE_SPACE_UPDATED = 'workspace-updated',
|
||||||
WORKSPACE_DELETED = 'workspace-deleted',
|
WORKSPACE_DELETED = 'workspace-deleted',
|
||||||
|
WORKSPACE_CREATE_EMBEDDINGS = 'workspace-create-embeddings',
|
||||||
WORKSPACE_DELETE_EMBEDDINGS = 'workspace-delete-embeddings',
|
WORKSPACE_DELETE_EMBEDDINGS = 'workspace-delete-embeddings',
|
||||||
|
|
||||||
GENERATE_PAGE_EMBEDDINGS = 'generate-page-embeddings',
|
GENERATE_PAGE_EMBEDDINGS = 'generate-page-embeddings',
|
||||||
|
|||||||
Reference in New Issue
Block a user