Skip to content

Commit

Permalink
fix dumb bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmatthis committed Jan 25, 2024
1 parent fc66c40 commit 434c121
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ export class DiscordMessageService {
attachmentText += attachmentResponse.text;
if (attachmentResponse.type === 'transcript') {
const maxMessageLength = 1800; // Reduced to 1800 to account for "message X of N" text
const fullAttachmenText = attachmentResponse.text;
const attachmentTextLength = fullAttachmenText.length;
const fullAttachmentText = attachmentResponse.text;
const attachmentTextLength = fullAttachmentText.length;

if (attachmentTextLength > maxMessageLength) {
const numberOfMessages = Math.ceil(
Expand All @@ -150,7 +150,7 @@ export class DiscordMessageService {
for (let i = 0; i < numberOfMessages; i++) {
const start = i * maxMessageLength;
const end = start + maxMessageLength;
const chunk = fullAttachmenText.slice(start, end);
const chunk = fullAttachmentText.slice(start, end);
const chunkMsg = `> Message ${
i + 1
} of ${numberOfMessages}\n\n${chunk}`;
Expand All @@ -164,21 +164,20 @@ export class DiscordMessageService {
);
}
} else {
await discordMessage.reply(fullAttachmenText);
await discordMessage.reply(fullAttachmentText);
}
}
attachmentText += 'END TEXT FROM ATTACHMENTS';
}
return { humanInputText, attachmentText };
}
return { humanInputText, attachmentText };
}

private async _sendFullResponseAsAttachment(
fullAiResponse: string,
discordMessage: Message<boolean>,
replyMessage: Message<boolean>,
) {
// add full chunk to the message as a `.md` attachement
const attachment = new AttachmentBuilder(Buffer.from(fullAiResponse), {
name: `full_response_to_discordMessageId_${discordMessage.id}.md`,
description:
Expand Down

0 comments on commit 434c121

Please sign in to comment.