From a33b82e8b1c5e876e93f01c946066db5f6a6fd99 Mon Sep 17 00:00:00 2001 From: darkskygit Date: Fri, 18 Apr 2025 06:56:35 +0000 Subject: [PATCH] fix(server): relax global embedding condition (#11791) --- .../server/src/plugins/copilot/context/job.ts | 6 ------ .../src/plugins/copilot/context/resolver.ts | 21 +------------------ 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/packages/backend/server/src/plugins/copilot/context/job.ts b/packages/backend/server/src/plugins/copilot/context/job.ts index 56470d629a..4d962c725e 100644 --- a/packages/backend/server/src/plugins/copilot/context/job.ts +++ b/packages/backend/server/src/plugins/copilot/context/job.ts @@ -77,12 +77,6 @@ export class CopilotContextDocJob { contextId?: string ) { if (!this.supportEmbedding) return; - const allowEmbedding = await this.models.workspace.allowEmbedding( - docs[0]?.workspaceId - ); - if (!allowEmbedding) { - return; - } for (const { workspaceId, docId } of docs) { await this.queue.add('copilot.embedding.docs', { diff --git a/packages/backend/server/src/plugins/copilot/context/resolver.ts b/packages/backend/server/src/plugins/copilot/context/resolver.ts index 7bf8e53a8f..6d20b8896e 100644 --- a/packages/backend/server/src/plugins/copilot/context/resolver.ts +++ b/packages/backend/server/src/plugins/copilot/context/resolver.ts @@ -21,7 +21,6 @@ import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs'; import { BlobQuotaExceeded, CallMetric, - CopilotEmbeddingDisabled, CopilotEmbeddingUnavailable, CopilotFailedToMatchContext, CopilotFailedToModifyContext, @@ -232,7 +231,6 @@ export class CopilotContextRootResolver { private readonly db: PrismaClient, private readonly ac: AccessController, private readonly event: EventBus, - private readonly models: Models, private readonly mutex: RequestMutex, private readonly chatSession: ChatSessionService, private readonly context: CopilotContextService @@ -348,10 +346,7 @@ export class CopilotContextRootResolver { .allowLocal() .assert('Workspace.Copilot'); - if ( - this.context.canEmbedding && - (await this.models.workspace.allowEmbedding(workspaceId)) - ) { + if (this.context.canEmbedding) { const total = await this.db.snapshot.count({ where: { workspaceId } }); const embedded = await this.db.snapshot.count({ where: { workspaceId, embedding: { isNot: null } }, @@ -457,13 +452,6 @@ export class CopilotContextResolver { } const session = await this.context.get(options.contextId); - const allowEmbedding = await this.models.workspace.allowEmbedding( - session.workspaceId - ); - if (!allowEmbedding) { - throw new CopilotEmbeddingDisabled(); - } - try { const records = await session.addCategoryRecord( options.type, @@ -533,13 +521,6 @@ export class CopilotContextResolver { } const session = await this.context.get(options.contextId); - const allowEmbedding = await this.models.workspace.allowEmbedding( - session.workspaceId - ); - if (!allowEmbedding) { - throw new CopilotEmbeddingDisabled(); - } - try { const record = await session.addDocRecord(options.docId);