optimization
This commit is contained in:
parent
bdd7c3bb8e
commit
e837ba3dc3
@ -223,53 +223,27 @@ class ollamarama:
|
|||||||
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 ", ".top_p ", ".repeat_penalty ")):
|
||||||
if message.startswith(".temperature "):
|
attr_name = message.split()[0][1:]
|
||||||
if message == ".temperature reset":
|
min_val, max_val, default_val = {
|
||||||
self.temperature = .9
|
"temperature": (0, 1, 0.9),
|
||||||
await self.send_message(room_id, f"Temperature set to {self.temperature}")
|
"top_p": (0, 1, 0.7),
|
||||||
else:
|
"repeat_penalty": (0, 2, 1.5)
|
||||||
try:
|
}[attr_name]
|
||||||
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.endswith(" reset"):
|
||||||
if message.startswith(".top_p "):
|
setattr(self, attr_name, default_val)
|
||||||
if message == ".top_p reset":
|
await self.send_message(room_id, f"{attr_name.capitalize()} set to {default_val}")
|
||||||
self.top_p = .7
|
|
||||||
await self.send_message(room_id, f"Top_p set to {self.top_p}")
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
top_p = float(message.split(" ", 1)[1])
|
value = float(message.split(" ", 1)[1])
|
||||||
if 0 <= top_p <=1:
|
if min_val <= value <= max_val:
|
||||||
self.top_p = top_p
|
setattr(self, attr_name, value)
|
||||||
await self.send_message(room_id, f"Top_p set to {self.top_p}")
|
await self.send_message(room_id, f"{attr_name.capitalize()} set to {value}")
|
||||||
else:
|
else:
|
||||||
await self.send_message(room_id, f"Invalid input, top_p is still {self.top_p}")
|
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, top_p is still {self.top_p}")
|
await self.send_message(room_id, f"Invalid input, {attr_name} is still {getattr(self, attr_name)}")
|
||||||
|
|
||||||
#repeat_penalty setting
|
|
||||||
if message.startswith(".repeat_penalty "):
|
|
||||||
if message == ".repeat_penalty reset":
|
|
||||||
self.repeat_penalty = 1.5
|
|
||||||
await self.send_message(room_id, f"Repeat_penalty set to {self.repeat_penalty}")
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
repeat_penalty = float(message.split(" ", 1)[1])
|
|
||||||
if 0 <= repeat_penalty <=2:
|
|
||||||
self.repeat_penalty = repeat_penalty
|
|
||||||
await self.send_message(room_id, f"Repeat_penalty set to {self.repeat_penalty}")
|
|
||||||
else:
|
|
||||||
await self.send_message(room_id, f"Invalid input, repeat_penalty is still {self.repeat_penalty}")
|
|
||||||
except:
|
|
||||||
await self.send_message(room_id, f"Invalid input, repeat_penalty is still {self.repeat_penalty}")
|
|
||||||
|
|
||||||
# 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):
|
||||||
|
Loading…
Reference in New Issue
Block a user