repo: lumina
action: commit
revision: 
path_from: 
revision_from: f0bf80c6d6562abfba56200d9a7c0f0451a8abfb:
path_to: 
revision_to: 
git.thebackupbox.net
lumina
git clone git://git.thebackupbox.net/lumina
commit f0bf80c6d6562abfba56200d9a7c0f0451a8abfb
Author: epoch 
Date:   Tue Apr 22 12:34:36 2025 -0500

    simple as shit LLM bot written in python3. batteries not included.

diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000000000000000000000000000000000000..5ddebe8c3cf8e5018ad2d80f5ee4462244cdcfd8
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,15 @@
+
+      |=====---
+     /      =  '''.
+    /        =     )
+   /         =    |
+  (   __     =   |
+   )-(_)----=   |
+ .'        =    |
+ ''.      =    |
+  '--    =    /
+  /   .---'''===
+  '--|---'''    \
+     |           \
+
+copyright is a spook
diff --git a/README b/README
new file mode 100644
index 0000000000000000000000000000000000000000..93f3f303630e6293aff9040a74e5d050682efa4d
--- /dev/null
+++ b/README
@@ -0,0 +1,8 @@
+This was tested with:
+https://huggingface.co/Mozilla/Llama-3.2-1B-Instruct-llamafile/blob/main/Llama-3.2-1B-Instruct.Q6_K.llamafile
+
+download it, chmod +x it, ./it
+
+trust that someone didn't shove malware in it.
+
+then run lumina.py and realize you forgot to change the IP address of the IRC server it connects to.
diff --git a/lumina.py b/lumina.py
new file mode 100644
index 0000000000000000000000000000000000000000..a117531ff250103a1a1dff4ba9a1738a334bf7fa
--- /dev/null
+++ b/lumina.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python3
+
+import socket
+import requests
+import json
+
+s=socket.socket()
+s.connect(("21.41.41.5",6667))
+s.send(b"NICK lumina\r\n")
+s.send(b"USER lumina lumina lumina :lumina\r\n")
+
+initial_prompt = "This is a conversation between User and Lumina, a friendly chatbot. Lumina is helpful, kind, honest, good at writing, and never fails to answer any requests immediately and with precision."
+
+### most of these values stolen from HTTP request that is made by a browser
+### when interacting with the default interface
+req = {
+  "stream":False,
+  "n_predict":400,
+  "temperature":0.7,
+  "stop":[
+    "",
+    "Lumina:",
+    "User:"
+  ],
+  "repeat_last_n":256,
+  "repeat_penalty":1.18,
+  "top_k":40,
+  "top_p":0.95,
+  "min_p":0.05,
+  "tfs_z":1,
+  "typical_p":1,
+  "presence_penalty":0,
+  "frequency_penalty":0,
+  "mirostat":0,
+  "mirostat_tau":5,
+  "mirostat_eta":0.1,
+  "grammar":"",
+  "n_probs":0,
+  "min_keep":0,
+  "image_data":[],
+  "cache_prompt":True,
+  "api_key":"",
+  "slot_id":0,
+  "prompt": initial_prompt
+}
+
+buf = b""
+while True:
+	buf += s.recv(4096)
+	while b"\r\n" in buf:
+		line, buf = buf.split(b"\r\n",maxsplit=1)
+		print(line)
+		a=line.split(b" ")
+		if a[0][0] == ord(b':') and b'!' in a[0] and b'@' in a[0]: # :nick!user@host
+			nick,x=a[0][1:].split(b"!")
+			user,host=x.split(b"@")
+			print("nick: {} user: {} host: {}".format(nick.decode(), user.decode(), host.decode()))
+		if a[1] == b"005":
+			s.send(b"JOIN #default\r\n")
+		if a[1] == b"KICK":
+			s.send(b"JOIN #default\r\n") # let's just try to rejoin on /any/ KICK we see.
+		if a[0] == b"PING":
+			s.send("PONG :{}\r\n".format(b" ".join(a[1:])).encode())
+		if a[1] == b"PRIVMSG":
+			target=a[2]
+			msg=b' '.join(a[3:])[1:]
+			if msg.startswith(b"lumina! reset prompt"):
+				s.send("PRIVMSG {} :\x01ACTION resets prompt\x01\r\n".format(target.decode()).encode())
+				req["prompt"]=initial_prompt
+			if msg.startswith(b"lumina! show prompt"):
+				for l in req["prompt"].split("\n"):
+					s.send("PRIVMSG {} : {}\r\n".format(target.decode(),l).encode())
+			if msg.startswith(b"lumina! help"):
+				s.send("PRIVMSG {} :commands: help, reset prompt, show prompt\r\n".format(target.decode()).encode() )
+			if not msg.startswith(b"lumina: "):
+				continue
+			msg=msg.split(b" ",maxsplit=1)[1]
+			print("{} <{}!{}@{}> {}".format(target.decode(),nick.decode(), user.decode(), host.decode(), msg.decode()))
+			req["prompt"]+="\n\nUser: {}\nLumina:".format(msg.decode())
+			httpresp = requests.post( "http://127.0.0.1:8080/completion", json=req )
+			resp = json.loads(httpresp.content)["content"].replace("<|eot_id|>","")
+			req["prompt"] += resp
+			for l in resp.split("\n"):
+				l=l.rstrip()
+				l=l.lstrip()
+				if l == "":
+					continue
+				print("sending: '{}'".format(l))
+				s.send("PRIVMSG {} :{}\r\n".format(target.decode(),l).encode())

-----END OF PAGE-----