Skip to content

Commit

Permalink
fix message persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmatthis committed Jul 11, 2024
1 parent 54b5eed commit d9792e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/interfaces/discord/services/discord-attachment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,9 @@ export class DiscordAttachmentService {

public async getAttachmentText(attachment: Attachment): Promise<string> {
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<string> {
this.logger.log('Downloading attachment:', attachment.name);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit d9792e5

Please sign in to comment.