fix(Thread): #1336 not allow creating too many unfinished thread (#1538)

Signed-off-by: James <james@jan.ai>
Co-authored-by: James <james@jan.ai>
This commit is contained in:
NamH 2024-01-14 16:22:29 +07:00 committed by GitHub
parent 5ad4eb2d05
commit 59564b710e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,10 +95,19 @@ export default class JSONConversationalExtension
* @param threadId The ID of the thread to delete.
*/
async deleteThread(threadId: string): Promise<void> {
return fs.rmdirSync(
await joinPath([JSONConversationalExtension._homeDir, `${threadId}`]),
{ recursive: true }
)
const path = await joinPath([
JSONConversationalExtension._homeDir,
`${threadId}`,
])
try {
if (await fs.existsSync(path)) {
await fs.rmdirSync(path, { recursive: true })
} else {
console.debug(`${path} does not exist`)
}
} catch (err) {
console.error(err)
}
}
async addNewMessage(message: ThreadMessage): Promise<void> {