Parcourir la source

Sort thread relations by updatedAt in getThreadsByAiAssistantId method

Shun Miyazawa il y a 9 mois
Parent
commit
ad52614f4d
1 fichiers modifiés avec 3 ajouts et 1 suppressions
  1. 3 1
      apps/app/src/features/openai/server/services/openai.ts

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

@@ -217,7 +217,9 @@ class OpenaiService implements IOpenaiService {
   }
   }
 
 
   async getThreadsByAiAssistantId(aiAssistantId: string, type: ThreadType = ThreadType.KNOWLEDGE): Promise<ThreadRelationDocument[]> {
   async getThreadsByAiAssistantId(aiAssistantId: string, type: ThreadType = ThreadType.KNOWLEDGE): Promise<ThreadRelationDocument[]> {
-    const threadRelations = await ThreadRelationModel.find({ aiAssistant: aiAssistantId, type });
+    const threadRelations = await ThreadRelationModel
+      .find({ aiAssistant: aiAssistantId, type })
+      .sort({ updatedAt: -1 })
     return threadRelations;
     return threadRelations;
   }
   }