From 6004eadd61c4f53c041b683e684449e3f910d4bf Mon Sep 17 00:00:00 2001 From: david Date: Tue, 31 Mar 2026 15:10:02 -0300 Subject: made it so it reads the system prompt and parameters from a file (this was vibecoded but it works so it's okay) --- bot.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'bot.py') 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) -- cgit v1.3-2-g0d8e