Ryotaro Nagahara 1 месяц назад
Родитель
Сommit
b76db51548
1 измененных файлов с 10 добавлено и 3 удалено
  1. 10 3
      apps/app/src/features/openai/server/services/openai.ts

+ 10 - 3
apps/app/src/features/openai/server/services/openai.ts

@@ -294,11 +294,18 @@ class OpenaiService implements IOpenaiService {
     userId?: string,
     type: ThreadType = ThreadType.KNOWLEDGE,
   ): Promise<ThreadRelationDocument[]> {
-    const threadRelations = await ThreadRelationModel.find({
+    const query: { aiAssistant: string; type: ThreadType; userId?: string } = {
       aiAssistant: aiAssistantId,
-      ...(userId != null && { userId }),
       type,
-    }).sort({ updatedAt: -1 });
+    };
+
+    if (userId != null) {
+      query.userId = userId;
+    }
+
+    const threadRelations = await ThreadRelationModel.find(query).sort({
+      updatedAt: -1,
+    });
     return threadRelations;
   }