feat(server): better guard for embedding not support env (#12472)

This commit is contained in:
darkskygit
2025-05-23 05:43:14 +00:00
parent 36a764ccc4
commit 3d9b13c53c

View File

@@ -108,7 +108,7 @@ export class CopilotContextDocJob {
workspaceId, workspaceId,
enableDocEmbedding, enableDocEmbedding,
}: Events['workspace.embedding']) { }: Events['workspace.embedding']) {
if (!this.supportEmbedding) return; if (!this.supportEmbedding || !this.embeddingClient) return;
if (enableDocEmbedding) { if (enableDocEmbedding) {
const toBeEmbedDocIds = const toBeEmbedDocIds =
@@ -130,7 +130,7 @@ export class CopilotContextDocJob {
@OnEvent('doc.indexer.updated') @OnEvent('doc.indexer.updated')
async addDocEmbeddingQueueFromEvent(doc: Events['doc.indexer.updated']) { async addDocEmbeddingQueueFromEvent(doc: Events['doc.indexer.updated']) {
if (!this.supportEmbedding) return; if (!this.supportEmbedding || !this.embeddingClient) return;
await this.queue.add('copilot.embedding.docs', { await this.queue.add('copilot.embedding.docs', {
workspaceId: doc.workspaceId, workspaceId: doc.workspaceId,
@@ -140,8 +140,6 @@ export class CopilotContextDocJob {
@OnEvent('doc.indexer.deleted') @OnEvent('doc.indexer.deleted')
async deleteDocEmbeddingQueueFromEvent(doc: Events['doc.indexer.deleted']) { async deleteDocEmbeddingQueueFromEvent(doc: Events['doc.indexer.deleted']) {
if (!this.supportEmbedding) return;
await this.models.copilotContext.deleteWorkspaceEmbedding( await this.models.copilotContext.deleteWorkspaceEmbedding(
doc.workspaceId, doc.workspaceId,
doc.docId doc.docId
@@ -238,7 +236,7 @@ export class CopilotContextDocJob {
workspaceId, workspaceId,
docId, docId,
}: Jobs['copilot.embedding.docs']) { }: Jobs['copilot.embedding.docs']) {
if (!this.supportEmbedding) return; if (!this.supportEmbedding || !this.embeddingClient) return;
if (workspaceId === docId || docId.includes('$')) return; if (workspaceId === docId || docId.includes('$')) return;
const signal = this.getWorkspaceSignal(workspaceId); const signal = this.getWorkspaceSignal(workspaceId);