From 4d941fe226b3852e34a4165de8a2639d3726e255 Mon Sep 17 00:00:00 2001 From: artie Date: Sat, 1 Feb 2025 21:25:22 +0100 Subject: [PATCH] ppp --- artemis/cogs/chat.py | 13 +++++++++---- data/prompt | 1 - 2 files changed, 9 insertions(+), 5 deletions(-) delete mode 100644 data/prompt diff --git a/artemis/cogs/chat.py b/artemis/cogs/chat.py index f787a83..29dbe36 100644 --- a/artemis/cogs/chat.py +++ b/artemis/cogs/chat.py @@ -107,10 +107,10 @@ class Chat(commands.Cog): self.lock = asyncio.Lock() def read_prompt(self): - return Path("data/prompt").read_text() + return Path("temp/prompt").read_text() if Path("temp/prompt").exists() else "" def write_prompt(self, prompt: str): - Path("data/prompt").write_text(prompt) + Path("temp/prompt").write_text(prompt) def replace_emojis(self, text: str) -> str: return EMOJI_RE.sub(lambda match: emoji_map[match.group(0)], text) @@ -124,7 +124,11 @@ class Chat(commands.Cog): return content def add_memory(self, role: str, message: str): - prompt = self.prompt + "Following is a user chat message directed at you." + "\n\n" + prompt = ( + self.prompt + + "The following is a user chat message directed at you, the format will be the same for subsequent messages, respond with only the message content, without specyfing actions." + + "\n\n" + ) if len(self.memory) == 0: message = prompt + message if len(self.memory) >= 15: @@ -152,6 +156,7 @@ class Chat(commands.Cog): chat_response = self.replace_emojis(chat_response) chat_response = self.strip_emojis(chat_response) chat_response = re.sub(r"[ ]{2,}", " ", chat_response) + chat_response = re.sub(r"[\n]{2,}", "\n", chat_response) self.add_assistant_memory(chat_response) return chat_response @@ -182,7 +187,7 @@ class Chat(commands.Cog): if not content: return - content = message.author.display_name + ": " + content + content = f"[USERNAME]: {message.author.display_name}\n[MESSAGE]: {content}" try: async with message.channel.typing(): diff --git a/data/prompt b/data/prompt deleted file mode 100644 index 539ba55..0000000 --- a/data/prompt +++ /dev/null @@ -1 +0,0 @@ -You're Artemis, a bot hanging out in this Discord server, you're friendly and can answer anything. \ No newline at end of file