|
|
@@ -98,12 +98,8 @@ export interface IOpenaiService {
|
|
|
): Promise<ThreadRelationDocument>;
|
|
|
getThreadsByAiAssistantId(
|
|
|
aiAssistantId: string,
|
|
|
- userId: string,
|
|
|
): Promise<ThreadRelationDocument[]>;
|
|
|
- deleteThread(
|
|
|
- threadRelationId: string,
|
|
|
- userId: string,
|
|
|
- ): Promise<ThreadRelationDocument>;
|
|
|
+ deleteThread(threadRelationId: string): Promise<ThreadRelationDocument>;
|
|
|
deleteExpiredThreads(limit: number, apiCallInterval: number): Promise<void>; // for CronJob
|
|
|
deleteObsoletedVectorStoreRelations(): Promise<void>; // for CronJob
|
|
|
deleteVectorStore(vectorStoreRelationId: string): Promise<void>;
|
|
|
@@ -297,12 +293,10 @@ class OpenaiService implements IOpenaiService {
|
|
|
|
|
|
async getThreadsByAiAssistantId(
|
|
|
aiAssistantId: string,
|
|
|
- userId: string,
|
|
|
type: ThreadType = ThreadType.KNOWLEDGE,
|
|
|
): Promise<ThreadRelationDocument[]> {
|
|
|
const threadRelations = await ThreadRelationModel.find({
|
|
|
aiAssistant: aiAssistantId,
|
|
|
- userId,
|
|
|
type,
|
|
|
}).sort({ updatedAt: -1 });
|
|
|
return threadRelations;
|
|
|
@@ -310,12 +304,8 @@ class OpenaiService implements IOpenaiService {
|
|
|
|
|
|
async deleteThread(
|
|
|
threadRelationId: string,
|
|
|
- userId: string,
|
|
|
): Promise<ThreadRelationDocument> {
|
|
|
- const threadRelation = await ThreadRelationModel.findOne({
|
|
|
- _id: threadRelationId,
|
|
|
- userId,
|
|
|
- });
|
|
|
+ const threadRelation = await ThreadRelationModel.findById(threadRelationId);
|
|
|
if (threadRelation == null) {
|
|
|
throw createError(404, 'ThreadRelation document does not exist');
|
|
|
}
|