Use the request message as always newest in the model history

This may fix #5 but I am not sure
This commit is contained in:
Wroclaw 2023-08-20 15:41:39 +02:00
parent 32dd705498
commit c9f7e3a62e

View file

@ -267,6 +267,7 @@ async function executeFromQueue(channel: string) {
messages.forEach(m => { Moderation.checkMessageNoReturn(m); });
const questionMessageId: string = message instanceof DiscordApi.Message ? message.id : '';
if (message instanceof DiscordApi.Message) {
channelQueue.startTyping();
}
@ -274,7 +275,11 @@ async function executeFromQueue(channel: string) {
await message.deferReply();
}
messages.sort((a, b) => b.createdTimestamp - a.createdTimestamp);
messages.sort((a, b) => {
if (a.id === questionMessageId) return -1;
if (b.id === questionMessageId) return 1;
return b.createdTimestamp - a.createdTimestamp;
});
OpenAImessages = toOpenAIMessages(messages.values());
let generatedMessage: ChatCompletionResponseMessage | undefined = undefined;