Merge pull request #68 from matrixgpt/refresh-chatgpt-session

Refresh chatgpt session
This commit is contained in:
bertybuttface 2023-01-28 00:20:05 +00:00 committed by GitHub
commit f35048e156
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,7 +49,24 @@ async function main() {
isMicrosoftLogin: (OPENAI_LOGIN_TYPE == "microsoft"),
isProAccount: OPENAI_PRO
})
await chatGPT.initSession()
chatGPT.initSession().then(() => {
LogService.info('ChatGPT session initialized');
});
// call `api.refreshSession()` every hour to refresh the session
setInterval(() => {
chatGPT.refreshSession().then(() => {
LogService.info('ChatGPT session reset');
});
}, 60 * 60 * 1000);
// call `api.resetSession()` every 24 hours to reset the session
setInterval(() => {
chatGPT.resetSession().then(() => {
LogService.info('ChatGPT session reset');
});
}, 24 * 60 * 60 * 1000);
// Automatically join rooms the bot is invited to
if (MATRIX_AUTOJOIN) {