Merge pull request #91 from max298/feature/send-error

Show errors from OpenAI
This commit is contained in:
bertybuttface 2023-02-08 16:08:22 +00:00 committed by GitHub
commit 43dc126241
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,7 +122,11 @@ export default class CommandHandler {
return; return;
} }
const result = await sendChatGPTMessage(this.chatGPT, await bodyWithoutPrefix, storedConversation); const result = await sendChatGPTMessage(this.chatGPT, await bodyWithoutPrefix, storedConversation)
.catch((error) => {
LogService.error(`OpenAI-API Error: ${error}`);
sendError(this.client, "The bot has encountered an error, please contact your administrator.", roomId, event.event_id);
});
await Promise.all([ await Promise.all([
this.client.setTyping(roomId, false, 500), this.client.setTyping(roomId, false, 500),
sendReply(this.client, roomId, this.getRootEventId(event), `${result.response}`, MATRIX_THREADS, MATRIX_RICH_TEXT) sendReply(this.client, roomId, this.getRootEventId(event), `${result.response}`, MATRIX_THREADS, MATRIX_RICH_TEXT)