Merge pull request #2 from h1ddenpr0cess20/dev

various updates
This commit is contained in:
Dustin 2023-12-22 16:47:59 -05:00 committed by GitHub
commit 19dfd7cb39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 12 deletions

View File

@ -70,7 +70,13 @@ python3 launcher.py
Resets all bot history and sets default model (admin only)
**.auth _user_**
Add user to admins (main admin only)
Add user to admins (bot owner only)
**.deauth _user_**
Remove user from admins (main admin only)
Remove user from admins (bot owner only)
**.gpersona _persona_***
Change global personality (bot owner only)
**.gpersona reset**
Reset global personality (bot owner only)

View File

@ -33,3 +33,7 @@ ollama pull stablelm-zephyr
ollama pull neural-chat
ollama pull mistral-openorca
ollama pull deepseek-llm:7b-chat
ollama pull wizard-vicuna-uncensored

View File

@ -16,6 +16,7 @@ class ollamarama:
self.username = username
self.password = password
self.channels = channels
self.default_personality = personality
self.personality = personality
self.client = AsyncClient(server, username)
@ -49,6 +50,8 @@ class ollamarama:
'stablelm-zephyr': 'ollama/stablelm-zephyr',
'neural-chat': 'ollama/neural-chat',
'mistral-openorca': 'ollama/mistral-openorca',
'deepseek-llm': 'ollama/deepseek-llm:7b-chat',
'wizard-vicuna-uncensored': 'ollama/wizard-vicuna-uncensored'
}
#set model
@ -137,7 +140,7 @@ class ollamarama:
except Exception as e:
print(e)
#Shrink history list for token size management
if len(self.messages[channel][sender]) > 30:
if len(self.messages[channel][sender]) > 24:
del self.messages[channel][sender][1:3] #delete the first set of question and answers
# change the personality of the bot
@ -215,18 +218,32 @@ Available models: {', '.join(sorted(list(self.models)))}''')
nick = message.split(" ", 1)[1].strip()
if nick != None:
self.admins.remove(nick)
await self.send_message(room_id, f"{nick} removed from admins")
await self.send_message(room_id, f"{nick} removed from admins")
#set new global personality
if message.startswith(".gpersona "):
m = message.split(" ", 1)[1]
if m != None:
if m == 'reset':
self.personality = self.default_personality
else:
self.personality = m.strip()
await self.send_message(room_id, f"Global personality set to {self.personality}")
#remove personality globally
if message == ".gstock":
pass #i'll figure this out later
# main AI response functionality
if message.startswith(".ai ") or message.startswith(self.bot_id):
m = message.split(" ", 1)
try:
m = m[1] + " [your response must be one paragraph or less]"
await self.add_history("user", room_id, sender, m)
await self.respond(room_id, sender, self.messages[room_id][sender])
except:
pass
if message != ".ai reset":
m = message.split(" ", 1)
try:
m = m[1] + " [your response must be one paragraph or less]"
await self.add_history("user", room_id, sender, m)
await self.respond(room_id, sender, self.messages[room_id][sender])
except:
pass
# collaborative functionality
if message.startswith(".x "):
m = message.split(" ", 2)
@ -263,7 +280,7 @@ Available models: {', '.join(sorted(list(self.models)))}''')
await self.respond(room_id, sender, self.messages[room_id][sender])
# reset bot to default personality
if message.startswith(".reset"):
if message.startswith(".reset") or message == ".ai reset": #some users keep forgetting the correct command
if room_id in self.messages:
if sender in self.messages[room_id]:
self.messages[room_id][sender].clear()
@ -311,8 +328,37 @@ f'''{self.bot_id}, an AI chatbot.
.stock
Remove personality and reset to standard model settings
Available at https://github.com/h1ddenpr0cess20/ollamarama-matrix
''')
if sender_display in self.admins:
await self.send_message(room_id, '''Admin commands:
.admins
List of users authorized to use these commands
.models
List available models
.model <model>
Change the model
.gpersona <personality>
Change default global personality (bot owner only)
.gpersona reset
Reset global personality (bot owner only)
.auth
Add an admin (bot owner only)
.deauth
Remove an admin (bot owner only)
''')
# main loop
async def main(self):