Ver Fonte

Fix logic for setting { isDefault: false }

Shun Miyazawa há 1 ano atrás
pai
commit
f68af1b15a
1 ficheiros alterados com 4 adições e 1 exclusões
  1. 4 1
      apps/app/src/features/openai/server/services/openai.ts

+ 4 - 1
apps/app/src/features/openai/server/services/openai.ts

@@ -829,10 +829,13 @@ class OpenaiService implements IOpenaiService {
       this.createVectorStoreFileWithStream(newVectorStoreRelation, conditions);
     }
 
+    if (data.shareScope !== AiAssistantShareScope.PUBLIC_ONLY && aiAssistant.isDefault) {
+      await AiAssistantModel.setDefault(aiAssistant._id, false);
+    }
+
     const newData = {
       ...data,
       vectorStore: newVectorStoreRelation ?? aiAssistant.vectorStore,
-      isDefault: data.shareScope !== AiAssistantShareScope.PUBLIC_ONLY ? false : aiAssistant.isDefault,
     };
 
     aiAssistant.set({ ...newData });