From 50c847d97452e1fee4ae34f50d64998999a12665 Mon Sep 17 00:00:00 2001 From: Paillat Date: Thu, 2 Nov 2023 17:26:15 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(ChatProcess.py):=20remove=20?= =?UTF-8?q?debug=20print=20statements=20=F0=9F=94=A7=20fix(claude.py):=20u?= =?UTF-8?q?pdate=20system=20message=20prompt=20to=20include=20explanation?= =?UTF-8?q?=20about=20the=20name=20in=20brackets=20The=20debug=20print=20s?= =?UTF-8?q?tatements=20in=20ChatProcess.py=20have=20been=20removed=20to=20?= =?UTF-8?q?clean=20up=20the=20code=20and=20improve=20readability.=20In=20c?= =?UTF-8?q?laude.py,=20the=20system=20message=20prompt=20has=20been=20upda?= =?UTF-8?q?ted=20to=20include=20an=20explanation=20about=20the=20name=20in?= =?UTF-8?q?=20brackets=20after=20"Human=20",=20providing=20more=20context?= =?UTF-8?q?=20to=20the=20users.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ChatProcess.py | 5 +++++ src/chatUtils/requesters/claude.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ChatProcess.py b/src/ChatProcess.py index 3d6eab8..d30d3d7 100644 --- a/src/ChatProcess.py +++ b/src/ChatProcess.py @@ -119,10 +119,15 @@ class Chat: else: role = "user" name = msg.author.display_name or msg.author.global_name or msg.author.name + print(f"""Global name: {msg.author.global_name} +Display name: {msg.author.display_name} +Name: {msg.author.name}""") # use re not make name match ^[a-zA-Z0-9_-]{1,64}$ by removing all non-alphanumeric characters name = re.sub(r"[^a-zA-Z0-9_-]", "", name, flags=re.UNICODE) + print(f"Name after regex: {name}") if name == "": name = msg.author.name + print(f"Name after regex: {name}") if not await moderate(self.openai_api_key, msg.content): self.context.append( { diff --git a/src/chatUtils/requesters/claude.py b/src/chatUtils/requesters/claude.py index ef7710b..3bde99b 100644 --- a/src/chatUtils/requesters/claude.py +++ b/src/chatUtils/requesters/claude.py @@ -13,7 +13,7 @@ async def claude(messages): prompt = "" for message in messages: if message["role"] == "system": - prompt += f"{HUMAN_PROMPT} {message['content']}" + prompt += f"{HUMAN_PROMPT} The name in brackets after \"Human \" is the username of the person sending the message\n{message['content']}" elif message["role"] == "assistant": prompt += f"{AI_PROMPT} {message['content']}" elif message["role"] == "user":