|
@@ -98,6 +98,7 @@ export interface IOpenaiService {
|
|
|
): Promise<ThreadRelationDocument>;
|
|
): Promise<ThreadRelationDocument>;
|
|
|
getThreadsByAiAssistantId(
|
|
getThreadsByAiAssistantId(
|
|
|
aiAssistantId: string,
|
|
aiAssistantId: string,
|
|
|
|
|
+ userId?: string,
|
|
|
): Promise<ThreadRelationDocument[]>;
|
|
): Promise<ThreadRelationDocument[]>;
|
|
|
deleteThread(threadRelationId: string): Promise<ThreadRelationDocument>;
|
|
deleteThread(threadRelationId: string): Promise<ThreadRelationDocument>;
|
|
|
deleteExpiredThreads(limit: number, apiCallInterval: number): Promise<void>; // for CronJob
|
|
deleteExpiredThreads(limit: number, apiCallInterval: number): Promise<void>; // for CronJob
|
|
@@ -290,12 +291,21 @@ class OpenaiService implements IOpenaiService {
|
|
|
|
|
|
|
|
async getThreadsByAiAssistantId(
|
|
async getThreadsByAiAssistantId(
|
|
|
aiAssistantId: string,
|
|
aiAssistantId: string,
|
|
|
|
|
+ userId?: string,
|
|
|
type: ThreadType = ThreadType.KNOWLEDGE,
|
|
type: ThreadType = ThreadType.KNOWLEDGE,
|
|
|
): Promise<ThreadRelationDocument[]> {
|
|
): Promise<ThreadRelationDocument[]> {
|
|
|
- const threadRelations = await ThreadRelationModel.find({
|
|
|
|
|
|
|
+ const query: { aiAssistant: string; type: ThreadType; userId?: string } = {
|
|
|
aiAssistant: aiAssistantId,
|
|
aiAssistant: aiAssistantId,
|
|
|
type,
|
|
type,
|
|
|
- }).sort({ updatedAt: -1 });
|
|
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ if (userId != null) {
|
|
|
|
|
+ query.userId = userId;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const threadRelations = await ThreadRelationModel.find(query).sort({
|
|
|
|
|
+ updatedAt: -1,
|
|
|
|
|
+ });
|
|
|
return threadRelations;
|
|
return threadRelations;
|
|
|
}
|
|
}
|
|
|
|
|
|