Merge pull request #3 from h1ddenpr0cess20/dev
added admin controls for temperature, top_p, repeat_penalty
This commit is contained in:
commit
2d72fedf70
11
README.md
11
README.md
@ -66,8 +66,17 @@ python3 launcher.py
|
|||||||
**.model _reset_**
|
**.model _reset_**
|
||||||
Reset to default model (admin only)
|
Reset to default model (admin only)
|
||||||
|
|
||||||
|
**.temperature**
|
||||||
|
Set temperature value between 0 and 1. To reset to default, type reset instead of a number. (bot owner only)
|
||||||
|
|
||||||
|
**.top_p**
|
||||||
|
Set top_p value between 0 and 1. To reset to default, type reset instead of a number. (bot owner only)
|
||||||
|
|
||||||
|
**.repeat_penalty**
|
||||||
|
Set repeat_penalty between 0 and 2. To reset to default, type reset instead of a number. (bot owner only)
|
||||||
|
|
||||||
**.clear**
|
**.clear**
|
||||||
Resets all bot history and sets default model (admin only)
|
Resets all bot history and sets default model (bot owner only)
|
||||||
|
|
||||||
**.auth _user_**
|
**.auth _user_**
|
||||||
Add user to admins (bot owner only)
|
Add user to admins (bot owner only)
|
||||||
|
@ -55,9 +55,13 @@ class ollamarama:
|
|||||||
|
|
||||||
}
|
}
|
||||||
#set model
|
#set model
|
||||||
self.default_model = self.models['solar']
|
self.default_model = self.models['zephyr']
|
||||||
self.model = self.default_model
|
self.model = self.default_model
|
||||||
|
|
||||||
|
self.temperature = .9
|
||||||
|
self.top_p = .7
|
||||||
|
self.repeat_penalty = 1.5
|
||||||
|
|
||||||
#authorized users for changing models
|
#authorized users for changing models
|
||||||
self.admins = admins
|
self.admins = admins
|
||||||
|
|
||||||
@ -109,11 +113,12 @@ class ollamarama:
|
|||||||
response = completion(
|
response = completion(
|
||||||
api_base="http://localhost:11434",
|
api_base="http://localhost:11434",
|
||||||
model=self.model,
|
model=self.model,
|
||||||
temperature=.9,
|
temperature=self.temperature,
|
||||||
top_p=.7,
|
top_p=self.top_p,
|
||||||
repeat_penalty=1.5,
|
repeat_penalty=self.repeat_penalty,
|
||||||
messages=message,
|
messages=message,
|
||||||
timeout=60)
|
timeout=60
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await self.send_message(channel, "Something went wrong")
|
await self.send_message(channel, "Something went wrong")
|
||||||
print(e)
|
print(e)
|
||||||
@ -199,12 +204,7 @@ Available models: {', '.join(sorted(list(self.models)))}''')
|
|||||||
self.model = self.default_model
|
self.model = self.default_model
|
||||||
await self.send_message(room_id, f"Model set to {self.model.removeprefix('ollama/')}")
|
await self.send_message(room_id, f"Model set to {self.model.removeprefix('ollama/')}")
|
||||||
|
|
||||||
#reset history for all users
|
#bot owner commands
|
||||||
if message == ".clear":
|
|
||||||
self.messages.clear()
|
|
||||||
self.model = self.default_model
|
|
||||||
await self.send_message(room_id, "Bot has been reset for everyone")
|
|
||||||
|
|
||||||
if sender_display == self.admins[0]:
|
if sender_display == self.admins[0]:
|
||||||
#add admins
|
#add admins
|
||||||
if message.startswith(".auth "):
|
if message.startswith(".auth "):
|
||||||
@ -234,6 +234,63 @@ Available models: {', '.join(sorted(list(self.models)))}''')
|
|||||||
if message == ".gstock":
|
if message == ".gstock":
|
||||||
pass #i'll figure this out later
|
pass #i'll figure this out later
|
||||||
|
|
||||||
|
#reset history for all users
|
||||||
|
if message == ".clear":
|
||||||
|
self.messages.clear()
|
||||||
|
self.model = self.default_model
|
||||||
|
self.temperature = .9
|
||||||
|
self.top_p = .7
|
||||||
|
self.repeat_penalty = 1.5
|
||||||
|
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(".top_p "):
|
||||||
|
if message == ".top_p reset":
|
||||||
|
self.top_p = .7
|
||||||
|
await self.send_message(room_id, f"Top_p set to {self.top_p}")
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
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.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):
|
||||||
if message != ".ai reset":
|
if message != ".ai reset":
|
||||||
@ -345,6 +402,18 @@ Available at https://github.com/h1ddenpr0cess20/ollamarama-matrix
|
|||||||
.model <model>
|
.model <model>
|
||||||
Change the model
|
Change the model
|
||||||
|
|
||||||
|
.temperature <#>
|
||||||
|
Set temperature value between 0 and 1. To reset to default, type reset instead of a number. (bot owner only)
|
||||||
|
|
||||||
|
.top_p <#>
|
||||||
|
Set top_p value between 0 and 1. To reset to default, type reset instead of a number. (bot owner only)
|
||||||
|
|
||||||
|
.repeat_penalty <#>
|
||||||
|
Set repeat_penalty between 0 and 2. To reset to default, type reset instead of a number. (bot owner only)
|
||||||
|
|
||||||
|
.clear
|
||||||
|
Reset bot for everyone (bot owner only)
|
||||||
|
|
||||||
.gpersona <personality>
|
.gpersona <personality>
|
||||||
Change default global personality (bot owner only)
|
Change default global personality (bot owner only)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user