mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 01:06:19 +00:00
🐛 fix(makeprompt.py): fix prompt generation logic for DM channels
✨ feat(makeprompt.py): add support for generating prompt with server and channel names, date and time, and pretend-to-be value
This commit is contained in:
@@ -305,15 +305,26 @@ async def chat_process(self, message):
|
|||||||
os.path.join(os.path.dirname(__file__), f"./prompts/{model}.txt")
|
os.path.join(os.path.dirname(__file__), f"./prompts/{model}.txt")
|
||||||
)
|
)
|
||||||
prompt = gpt_3_5_turbo_prompt[:] # copy the prompt but to dnot reference it
|
prompt = gpt_3_5_turbo_prompt[:] # copy the prompt but to dnot reference it
|
||||||
|
if not isinstance(message.channel, discord.DMChannel):
|
||||||
prompt = (
|
prompt = (
|
||||||
prompt.replace("[prompt-prefix]", prompt_prefix)
|
prompt.replace("[prompt-prefix]", prompt_prefix)
|
||||||
.replace("[server-name]", message.guild.name)
|
.replace("[server-name]", message.guild.name)
|
||||||
.replace(
|
.replace(
|
||||||
"[channel-name]",
|
"[channel-name]",
|
||||||
message.channel.name
|
message.channel.name
|
||||||
if isinstance(message.channel, discord.TextChannel)
|
)
|
||||||
else "DM-channel",
|
.replace(
|
||||||
|
"[date-and-time]", datetime.datetime.utcnow().strftime("%d/%m/%Y %H:%M:%S")
|
||||||
|
)
|
||||||
|
.replace("[pretend-to-be]", pretend_to_be)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
prompt = (
|
||||||
|
prompt.replace("[prompt-prefix]", prompt_prefix)
|
||||||
|
.replace("[server-name]", "DM-channel")
|
||||||
|
.replace(
|
||||||
|
"[channel-name]",
|
||||||
|
"DM-channel"
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"[date-and-time]", datetime.datetime.utcnow().strftime("%d/%m/%Y %H:%M:%S")
|
"[date-and-time]", datetime.datetime.utcnow().strftime("%d/%m/%Y %H:%M:%S")
|
||||||
|
|||||||
Reference in New Issue
Block a user