commit
f636b5aebb
@ -30,7 +30,7 @@ class ollamarama:
|
|||||||
self.messages = {}
|
self.messages = {}
|
||||||
|
|
||||||
#prompt parts
|
#prompt parts
|
||||||
self.prompt = ("you are ", ". roleplay and speak in the first person and never break character.")
|
self.prompt = ("you are ", ". roleplay and speak in the first person and never break character. keep your responses brief and to the point.")
|
||||||
|
|
||||||
self.models = config[0]['models']
|
self.models = config[0]['models']
|
||||||
#set model
|
#set model
|
||||||
@ -160,11 +160,11 @@ class ollamarama:
|
|||||||
sender = event.sender
|
sender = event.sender
|
||||||
sender_display = await self.display_name(sender)
|
sender_display = await self.display_name(sender)
|
||||||
room_id = room.room_id
|
room_id = room.room_id
|
||||||
user = await self.display_name(event.sender)
|
|
||||||
|
|
||||||
#check if the message was sent after joining and not by the bot
|
#check if the message was sent after joining and not by the bot
|
||||||
if message_time > self.join_time and sender != self.username:
|
if message_time > self.join_time and sender != self.username:
|
||||||
|
user = await self.display_name(event.sender)
|
||||||
#admin commands
|
#admin commands
|
||||||
if message == ".admins":
|
if message == ".admins":
|
||||||
await self.send_message(room_id, f"Bot admins: {', '.join(self.admins)}")
|
await self.send_message(room_id, f"Bot admins: {', '.join(self.admins)}")
|
||||||
@ -222,61 +222,35 @@ class ollamarama:
|
|||||||
self.top_p = .7
|
self.top_p = .7
|
||||||
self.repeat_penalty = 1.5
|
self.repeat_penalty = 1.5
|
||||||
await self.send_message(room_id, "Bot has been reset for everyone")
|
await self.send_message(room_id, "Bot has been reset for everyone")
|
||||||
|
|
||||||
#temperature setting
|
|
||||||
if message.startswith(".temperature "):
|
|
||||||
if message == ".temperature reset":
|
|
||||||
self.temperature = .9
|
|
||||||
await self.send_message(room_id, f"Temperature set to {self.temperature}")
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
temp = float(message.split(" ", 1)[1])
|
|
||||||
if 0 <= temp <=1:
|
|
||||||
self.temperature = temp
|
|
||||||
await self.send_message(room_id, f"Temperature set to {self.temperature}")
|
|
||||||
else:
|
|
||||||
await self.send_message(room_id, f"Invalid input, temperature is still {self.temperature}")
|
|
||||||
except:
|
|
||||||
await self.send_message(room_id, f"Invalid input, temperature is still {self.temperature}")
|
|
||||||
|
|
||||||
#top_p setting
|
if message.startswith((".temperature ", ".top_p ", ".repeat_penalty ")):
|
||||||
if message.startswith(".top_p "):
|
attr_name = message.split()[0][1:]
|
||||||
if message == ".top_p reset":
|
min_val, max_val, default_val = {
|
||||||
self.top_p = .7
|
"temperature": (0, 1, 0.9),
|
||||||
await self.send_message(room_id, f"Top_p set to {self.top_p}")
|
"top_p": (0, 1, 0.7),
|
||||||
else:
|
"repeat_penalty": (0, 2, 1.5)
|
||||||
try:
|
}[attr_name]
|
||||||
top_p = float(message.split(" ", 1)[1])
|
|
||||||
if 0 <= top_p <=1:
|
|
||||||
self.top_p = top_p
|
|
||||||
await self.send_message(room_id, f"Top_p set to {self.top_p}")
|
|
||||||
else:
|
|
||||||
await self.send_message(room_id, f"Invalid input, top_p is still {self.top_p}")
|
|
||||||
except:
|
|
||||||
await self.send_message(room_id, f"Invalid input, top_p is still {self.top_p}")
|
|
||||||
|
|
||||||
#repeat_penalty setting
|
if message.endswith(" reset"):
|
||||||
if message.startswith(".repeat_penalty "):
|
setattr(self, attr_name, default_val)
|
||||||
if message == ".repeat_penalty reset":
|
await self.send_message(room_id, f"{attr_name.capitalize()} set to {default_val}")
|
||||||
self.repeat_penalty = 1.5
|
|
||||||
await self.send_message(room_id, f"Repeat_penalty set to {self.repeat_penalty}")
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
repeat_penalty = float(message.split(" ", 1)[1])
|
value = float(message.split(" ", 1)[1])
|
||||||
if 0 <= repeat_penalty <=2:
|
if min_val <= value <= max_val:
|
||||||
self.repeat_penalty = repeat_penalty
|
setattr(self, attr_name, value)
|
||||||
await self.send_message(room_id, f"Repeat_penalty set to {self.repeat_penalty}")
|
await self.send_message(room_id, f"{attr_name.capitalize()} set to {value}")
|
||||||
else:
|
else:
|
||||||
await self.send_message(room_id, f"Invalid input, repeat_penalty is still {self.repeat_penalty}")
|
await self.send_message(room_id, f"Invalid input, {attr_name} is still {getattr(self, attr_name)}")
|
||||||
except:
|
except:
|
||||||
await self.send_message(room_id, f"Invalid input, repeat_penalty is still {self.repeat_penalty}")
|
await self.send_message(room_id, f"Invalid input, {attr_name} is still {getattr(self, attr_name)}")
|
||||||
|
|
||||||
# main AI response functionality
|
# main AI response functionality
|
||||||
if message.startswith(".ai ") or message.startswith(self.bot_id):
|
if message.startswith(".ai ") or message.startswith(self.bot_id):
|
||||||
if message != ".ai reset":
|
if message != ".ai reset":
|
||||||
m = message.split(" ", 1)
|
m = message.split(" ", 1)
|
||||||
try:
|
try:
|
||||||
m = m[1] + " [your response must be one paragraph or less]"
|
m = m[1]# + " [your response must be one paragraph or less]"
|
||||||
await self.add_history("user", room_id, sender, m)
|
await self.add_history("user", room_id, sender, m)
|
||||||
await self.respond(room_id, sender, self.messages[room_id][sender])
|
await self.respond(room_id, sender, self.messages[room_id][sender])
|
||||||
except:
|
except:
|
||||||
@ -288,7 +262,7 @@ class ollamarama:
|
|||||||
if len(m) > 1:
|
if len(m) > 1:
|
||||||
disp_name = m[0]
|
disp_name = m[0]
|
||||||
name_id = ""
|
name_id = ""
|
||||||
m = m[1] + " [your response must be one paragraph or less]"
|
m = m[1]# + " [your response must be one paragraph or less]"
|
||||||
if room_id in self.messages:
|
if room_id in self.messages:
|
||||||
for user in self.messages[room_id]:
|
for user in self.messages[room_id]:
|
||||||
try:
|
try:
|
||||||
@ -304,7 +278,7 @@ class ollamarama:
|
|||||||
#change personality
|
#change personality
|
||||||
if message.startswith(".persona "):
|
if message.startswith(".persona "):
|
||||||
m = message.split(" ", 1)
|
m = message.split(" ", 1)
|
||||||
m = m[1] + " [your response must be one paragraph or less]"
|
m = m[1]# + " [your response must be one paragraph or less]"
|
||||||
|
|
||||||
await self.persona(room_id, sender, m)
|
await self.persona(room_id, sender, m)
|
||||||
await self.respond(room_id, sender, self.messages[room_id][sender])
|
await self.respond(room_id, sender, self.messages[room_id][sender])
|
||||||
|
Loading…
Reference in New Issue
Block a user