From 68ff639f27dfb980a38a26b5e99a42ff1549e1ec Mon Sep 17 00:00:00 2001 From: Paillat Date: Tue, 15 Aug 2023 11:33:29 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(makeprompt.py):=20reverse=20?= =?UTF-8?q?the=20order=20of=20fetched=20messages=20to=20ensure=20correct?= =?UTF-8?q?=20chronological=20order=20=F0=9F=94=A5=20chore(makeprompt.py):?= =?UTF-8?q?=20remove=20unnecessary=20oldest=5Ffirst=20parameter=20in=20cha?= =?UTF-8?q?nnel.history()=20calls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/makeprompt.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/makeprompt.py b/src/makeprompt.py index 29f1e77..d293b7f 100644 --- a/src/makeprompt.py +++ b/src/makeprompt.py @@ -39,19 +39,20 @@ def is_ignorable(content): async def fetch_messages_history(channel: discord.TextChannel, limit, original_message): messages = [] if original_message == None: - async for msg in channel.history(limit=100, oldest_first=True): + async for msg in channel.history(limit=100): if not is_ignorable(msg.content): messages.append(msg) if len(messages) == limit: break else: async for msg in channel.history( - limit=100, before=original_message, oldest_first=True + limit=100, before=original_message ): if not is_ignorable(msg.content): messages.append(msg) if len(messages) == limit: break + messages.reverse() return messages @@ -142,6 +143,7 @@ async def chatgpt_process( functions=called_functions, # function_call="auto", ) + print(msgs) response = response["choices"][0]["message"] # type: ignore if response.get("function_call"): function_call = response.get("function_call")