aboutsummaryrefslogtreecommitdiff
path: root/bot.py
diff options
context:
space:
mode:
Diffstat (limited to 'bot.py')
-rw-r--r--bot.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/bot.py b/bot.py
index f3c5da0..aed3f63 100644
--- a/bot.py
+++ b/bot.py
@@ -18,7 +18,8 @@ def ignore_connection_closed_ok(loop, context): #this doesn't fucking work
loop.default_exception_handler(context)
-system_prompt = "you are a funny discord user that uses discrd"
+def load_system_prompt() -> str:
+ return Path("system_prompt.txt").read_text(encoding="utf-8")
FILES_DIR = Path("files")
LOG_DIR = FILES_DIR / "log"
@@ -91,13 +92,13 @@ def load_longterm() -> list[str]:
log_error(f"[{timestamp()}] error reading longterm: {e}")
return []
-def build_payload(sys_prompt: str, user_input: str, rebuild: bool = False) -> str:
+def build_payload(user_input: str, rebuild: bool = False) -> str:
global vector_db_ready
should_rebuild = rebuild or not vector_db_ready # always rebuild on first ever message
if should_rebuild:
vector_db_ready = True
return json.dumps({
- "system_prompt": sys_prompt,
+ "system_prompt": load_system_prompt(),
"user_input": user_input,
"shortterm": load_shortterm(),
"longterm": load_longterm(),
@@ -184,7 +185,6 @@ async def random_dm():
continue
victim = random.choice(members)
payload = build_payload(
- system_prompt,
f"System: you are sending a dm to {victim}, write a long, playful story or an over-the-top pun monologue about anything. "
"It should sound like something faggot-chan would post when she's bored — chaotic, funny, and full of personality (at least 20 words)."
"keep in mind this is a dm so make it a bit personal"
@@ -215,7 +215,6 @@ async def random_message():
channel = discord.utils.get(guild.text_channels, name="general")
if channel:
payload = build_payload(
- system_prompt,
"System: write a long, playful story or an over-the-top pun monologue about cheese. or anything random"
"it should sound like something faggot-chan would post when she's bored."
"chaotic, funny, and full of personality (at least 15 words and no more than 20)"
@@ -361,7 +360,7 @@ async def on_message(message):
user_input = f'{message.author} replied to {replied_message.author} saying: "{replied_content}" with reply: "{content}"'
else:
user_input = f"{message.author} said in DM: {content}"
- payload = build_payload(system_prompt, user_input, rebuild)
+ payload = build_payload(user_input, rebuild)
stop_typing = asyncio.Event()
asyncio.create_task(keep_typing(message.channel, stop_typing))
ok, result = await call_main(payload)
@@ -392,7 +391,7 @@ async def on_message(message):
else:
user_input = f"{message.author} said: {content}"
- payload = build_payload(system_prompt, user_input, rebuild)
+ payload = build_payload(user_input, rebuild)
stop_typing = asyncio.Event()
asyncio.create_task(keep_typing(message.channel, stop_typing))
ok, result = await call_main(payload)