Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit adbf754

Browse files
committed
adding clean thread api
Signed-off-by: James <namnh0122@gmail.com>
1 parent aaa639a commit adbf754

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

cortex-js/src/infrastructure/controllers/threads.controller.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,24 @@ export class ThreadsController {
215215
);
216216
}
217217

218+
@ApiOperation({
219+
summary: 'Clean thread',
220+
description: 'Deletes all messages in a thread.',
221+
tags: ['Threads'],
222+
parameters: [
223+
{
224+
in: 'path',
225+
name: 'thread_id',
226+
required: true,
227+
description: 'The ID of the thread to clean.',
228+
},
229+
],
230+
})
231+
@Post(':thread_id/clean')
232+
async cleanThread(@Param('thread_id') threadId: string) {
233+
return this.threadsUsecases.clean(threadId);
234+
}
235+
218236
@ApiOperation({
219237
summary: 'Delete message',
220238
description: 'Deletes a message.',

cortex-js/src/usecases/threads/threads.usecases.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,9 @@ export class ThreadsUsecases {
215215
// we still allow user to delete message even if the thread is not there
216216
return this.getMessageOrThrow(messageId);
217217
}
218+
219+
async clean(threadId: string) {
220+
await this.getThreadOrThrow(threadId);
221+
await this.messageRepository.delete({ thread_id: threadId });
222+
}
218223
}

0 commit comments

Comments
 (0)