fix(server): relax global embedding condition (#11791)
This commit is contained in:
@@ -77,12 +77,6 @@ export class CopilotContextDocJob {
|
|||||||
contextId?: string
|
contextId?: string
|
||||||
) {
|
) {
|
||||||
if (!this.supportEmbedding) return;
|
if (!this.supportEmbedding) return;
|
||||||
const allowEmbedding = await this.models.workspace.allowEmbedding(
|
|
||||||
docs[0]?.workspaceId
|
|
||||||
);
|
|
||||||
if (!allowEmbedding) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const { workspaceId, docId } of docs) {
|
for (const { workspaceId, docId } of docs) {
|
||||||
await this.queue.add('copilot.embedding.docs', {
|
await this.queue.add('copilot.embedding.docs', {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs';
|
|||||||
import {
|
import {
|
||||||
BlobQuotaExceeded,
|
BlobQuotaExceeded,
|
||||||
CallMetric,
|
CallMetric,
|
||||||
CopilotEmbeddingDisabled,
|
|
||||||
CopilotEmbeddingUnavailable,
|
CopilotEmbeddingUnavailable,
|
||||||
CopilotFailedToMatchContext,
|
CopilotFailedToMatchContext,
|
||||||
CopilotFailedToModifyContext,
|
CopilotFailedToModifyContext,
|
||||||
@@ -232,7 +231,6 @@ export class CopilotContextRootResolver {
|
|||||||
private readonly db: PrismaClient,
|
private readonly db: PrismaClient,
|
||||||
private readonly ac: AccessController,
|
private readonly ac: AccessController,
|
||||||
private readonly event: EventBus,
|
private readonly event: EventBus,
|
||||||
private readonly models: Models,
|
|
||||||
private readonly mutex: RequestMutex,
|
private readonly mutex: RequestMutex,
|
||||||
private readonly chatSession: ChatSessionService,
|
private readonly chatSession: ChatSessionService,
|
||||||
private readonly context: CopilotContextService
|
private readonly context: CopilotContextService
|
||||||
@@ -348,10 +346,7 @@ export class CopilotContextRootResolver {
|
|||||||
.allowLocal()
|
.allowLocal()
|
||||||
.assert('Workspace.Copilot');
|
.assert('Workspace.Copilot');
|
||||||
|
|
||||||
if (
|
if (this.context.canEmbedding) {
|
||||||
this.context.canEmbedding &&
|
|
||||||
(await this.models.workspace.allowEmbedding(workspaceId))
|
|
||||||
) {
|
|
||||||
const total = await this.db.snapshot.count({ where: { workspaceId } });
|
const total = await this.db.snapshot.count({ where: { workspaceId } });
|
||||||
const embedded = await this.db.snapshot.count({
|
const embedded = await this.db.snapshot.count({
|
||||||
where: { workspaceId, embedding: { isNot: null } },
|
where: { workspaceId, embedding: { isNot: null } },
|
||||||
@@ -457,13 +452,6 @@ export class CopilotContextResolver {
|
|||||||
}
|
}
|
||||||
const session = await this.context.get(options.contextId);
|
const session = await this.context.get(options.contextId);
|
||||||
|
|
||||||
const allowEmbedding = await this.models.workspace.allowEmbedding(
|
|
||||||
session.workspaceId
|
|
||||||
);
|
|
||||||
if (!allowEmbedding) {
|
|
||||||
throw new CopilotEmbeddingDisabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const records = await session.addCategoryRecord(
|
const records = await session.addCategoryRecord(
|
||||||
options.type,
|
options.type,
|
||||||
@@ -533,13 +521,6 @@ export class CopilotContextResolver {
|
|||||||
}
|
}
|
||||||
const session = await this.context.get(options.contextId);
|
const session = await this.context.get(options.contextId);
|
||||||
|
|
||||||
const allowEmbedding = await this.models.workspace.allowEmbedding(
|
|
||||||
session.workspaceId
|
|
||||||
);
|
|
||||||
if (!allowEmbedding) {
|
|
||||||
throw new CopilotEmbeddingDisabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const record = await session.addDocRecord(options.docId);
|
const record = await session.addDocRecord(options.docId);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user