improvements

This commit is contained in:
Dustin 2024-04-27 00:57:23 -04:00
parent b72fb9f382
commit bdd7c3bb8e
3 changed files with 32 additions and 44 deletions

View File

@ -1,16 +1,22 @@
[ [
{ {
"llama3": "ollama/llama3", "models":
"wizardlm2": "ollama/wizardlm2", {
"phi3": "ollama/phi3", "llama3": "ollama/llama3",
"zephyr": "ollama/zephyr", "wizardlm2": "ollama/wizardlm2",
"solar": "ollama/solar", "phi3": "ollama/phi3",
"mistral": "ollama/mistral", "zephyr": "ollama/zephyr",
"codellama": "ollama/codellama", "solar": "ollama/solar",
"dolphin-mistral": "ollama/dolphin-mistral", "mistral": "ollama/mistral",
"dolphin-llama3": "ollama/dolphin-llama3", "codellama": "ollama/codellama",
"gemma": "ollama/gemma", "dolphin-mistral": "ollama/dolphin-mistral",
"codegemma": "ollama/codegemma" "dolphin-llama3": "ollama/dolphin-llama3",
"gemma": "ollama/gemma",
"codegemma": "ollama/codegemma"
},
"default_model": "llama3"
}, },
{ {
"server": "https://matrix.org", "server": "https://matrix.org",

View File

@ -20,9 +20,7 @@
Available at https://github.com/h1ddenpr0cess20/ollamarama-matrix Available at https://github.com/h1ddenpr0cess20/ollamarama-matrix
~~~ ~~~
.admins .admins
List of users authorized to use these commands List of users authorized to use these commands

View File

@ -12,16 +12,17 @@ import datetime
import asyncio import asyncio
class ollamarama: class ollamarama:
def __init__(self, server, username, password, channels, personality, admins): def __init__(self):
self.server = server #load config file
self.username = username with open("config.json", "r") as f:
self.password = password config = json.load(f)
self.channels = channels f.close()
self.default_personality = personality
self.personality = personality self.server, self.username, self.password, self.channels, self.default_personality, self.admins = config[1].values()
self.personality = self.default_personality
self.client = AsyncClient(server, username)
self.client = AsyncClient(self.server, self.username)
# time program started and joined channels # time program started and joined channels
self.join_time = datetime.datetime.now() self.join_time = datetime.datetime.now()
@ -31,12 +32,9 @@ class ollamarama:
#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.")
#open config.json self.models = config[0]['models']
with open("config.json", "r") as f:
self.models = json.load(f)[0]
f.close()
#set model #set model
self.default_model = self.models['llama3'] self.default_model = self.models[config[0]['default_model']]
self.model = self.default_model self.model = self.default_model
#no idea if optimal, change if necessary #no idea if optimal, change if necessary
@ -44,15 +42,11 @@ class ollamarama:
self.top_p = .7 self.top_p = .7
self.repeat_penalty = 1.5 self.repeat_penalty = 1.5
#authorized users for changing models
self.admins = admins
#load help menu #load help menu
with open("help.txt", "r") as f: with open("help.txt", "r") as f:
self.help, self.help_admin = f.read().split("~~~") self.help, self.help_admin = f.read().split("~~~")
f.close() f.close()
# get the display name for a user # get the display name for a user
async def display_name(self, user): async def display_name(self, user):
try: try:
@ -376,16 +370,6 @@ class ollamarama:
await self.client.sync_forever(timeout=30000) await self.client.sync_forever(timeout=30000)
if __name__ == "__main__": if __name__ == "__main__":
#load config file bot = ollamarama()
with open("config.json", "r") as f:
config = json.load(f)
f.close()
server, username, password, channels, personality, admins = config[1].values()
# create bot instance
bot = ollamarama(server, username, password, channels, personality, admins)
# run main function loop
asyncio.get_event_loop().run_until_complete(bot.main()) asyncio.get_event_loop().run_until_complete(bot.main())