aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bot.py13
-rw-r--r--main.py13
2 files changed, 10 insertions, 16 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)
diff --git a/main.py b/main.py
index 74533f5..ad5dc4f 100644
--- a/main.py
+++ b/main.py
@@ -4,13 +4,13 @@ import json
import re # thank you claude
import ollama
import websockets
+from pathlib import Path
from websockets.server import serve
from datetime import datetime
chatmodel = "hf.co/Stetsoncody/Llama-3.2-3B-Instruct-abliterated-GGUF:Q4_K_M"
embedmodel = 'hf.co/CompendiumLabs/bge-base-en-v1.5-gguf'
-NUM_THREADS = 6 # hardcoded since threads.txt is gone, change if needed
def times() -> str:
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
@@ -151,17 +151,12 @@ async def ollamachat(websocket):
messages.insert(0, {"role": "system", "content": system_prompt + rag_block})
+ params = json.loads(Path("config/params.json").read_text())
+
response = ollama.chat(
model=chatmodel,
messages=messages,
- options={
- "temperature": 0.83,
- "top_p": 0.9,
- "top_k": 40,
- "repeat_penalty": 1.1,
- "num_predict": 1024,
- "num_thread": NUM_THREADS,
- }
+ options=params,
)
# strip <think> blocks in case the model ignores think=False, thank you claude