From d9792e54565f53bc7a09d1c2e587b16367d73850 Mon Sep 17 00:00:00 2001 From: jonmatthis Date: Thu, 11 Jul 2024 10:59:54 -0400 Subject: [PATCH] fix message persistence --- .../discord/services/discord-attachment.service.ts | 7 ++----- .../discord/services/discord-persistence.service.ts | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/interfaces/discord/services/discord-attachment.service.ts b/src/interfaces/discord/services/discord-attachment.service.ts index 5cbb78a..41ed43d 100644 --- a/src/interfaces/discord/services/discord-attachment.service.ts +++ b/src/interfaces/discord/services/discord-attachment.service.ts @@ -184,12 +184,9 @@ export class DiscordAttachmentService { public async getAttachmentText(attachment: Attachment): Promise { const attachmentPath = await this.downloadAttachment(attachment); - try { - return fs.readFileSync(attachmentPath, 'utf8'); - } catch (err) { - console.error(err); - } + return await fs.promises.readFile(attachmentPath, 'utf8'); } + public async downloadAttachment(attachment: Attachment): Promise { this.logger.log('Downloading attachment:', attachment.name); try { diff --git a/src/interfaces/discord/services/discord-persistence.service.ts b/src/interfaces/discord/services/discord-persistence.service.ts index be275bf..22bc0cc 100644 --- a/src/interfaces/discord/services/discord-persistence.service.ts +++ b/src/interfaces/discord/services/discord-persistence.service.ts @@ -121,7 +121,7 @@ export class DiscordPersistenceService { chatAttachmentText += '\n___\n'; chatAttachmentText += '\nCONTEXT INSTRUCTIONS/SYSTEM PROMPT:\n\n```\n'; chatAttachmentText += `${contextInstructions}\n`; - chatAttachmentText += '```\n'; + chatAttachmentText += '```\n---\n## CONVERSATION\n\n'; } else { // Fetch the existing attachment content chatAttachmentText = await this._attachementService.getAttachmentText(