diff --git a/config.json b/config.json index 53d419d..e573679 100644 --- a/config.json +++ b/config.json @@ -1,16 +1,22 @@ [ { - "llama3": "ollama/llama3", - "wizardlm2": "ollama/wizardlm2", - "phi3": "ollama/phi3", - "zephyr": "ollama/zephyr", - "solar": "ollama/solar", - "mistral": "ollama/mistral", - "codellama": "ollama/codellama", - "dolphin-mistral": "ollama/dolphin-mistral", - "dolphin-llama3": "ollama/dolphin-llama3", - "gemma": "ollama/gemma", - "codegemma": "ollama/codegemma" + "models": + { + "llama3": "ollama/llama3", + "wizardlm2": "ollama/wizardlm2", + "phi3": "ollama/phi3", + "zephyr": "ollama/zephyr", + "solar": "ollama/solar", + "mistral": "ollama/mistral", + "codellama": "ollama/codellama", + "dolphin-mistral": "ollama/dolphin-mistral", + "dolphin-llama3": "ollama/dolphin-llama3", + "gemma": "ollama/gemma", + "codegemma": "ollama/codegemma" + }, + + "default_model": "llama3" + }, { "server": "https://matrix.org", diff --git a/help.txt b/help.txt index d091e88..a58aebb 100644 --- a/help.txt +++ b/help.txt @@ -20,9 +20,7 @@ Available at https://github.com/h1ddenpr0cess20/ollamarama-matrix - ~~~ - .admins List of users authorized to use these commands diff --git a/ollamarama.py b/ollamarama.py index 61e124f..a889d80 100644 --- a/ollamarama.py +++ b/ollamarama.py @@ -12,16 +12,17 @@ import datetime import asyncio class ollamarama: - def __init__(self, server, username, password, channels, personality, admins): - self.server = server - self.username = username - self.password = password - self.channels = channels - self.default_personality = personality - self.personality = personality - - self.client = AsyncClient(server, username) - + def __init__(self): + #load config file + with open("config.json", "r") as f: + config = json.load(f) + f.close() + + self.server, self.username, self.password, self.channels, self.default_personality, self.admins = config[1].values() + self.personality = self.default_personality + + self.client = AsyncClient(self.server, self.username) + # time program started and joined channels self.join_time = datetime.datetime.now() @@ -31,12 +32,9 @@ class ollamarama: #prompt parts self.prompt = ("you are ", ". roleplay and speak in the first person and never break character.") - #open config.json - with open("config.json", "r") as f: - self.models = json.load(f)[0] - f.close() + self.models = config[0]['models'] #set model - self.default_model = self.models['llama3'] + self.default_model = self.models[config[0]['default_model']] self.model = self.default_model #no idea if optimal, change if necessary @@ -44,15 +42,11 @@ class ollamarama: self.top_p = .7 self.repeat_penalty = 1.5 - #authorized users for changing models - self.admins = admins - #load help menu with open("help.txt", "r") as f: self.help, self.help_admin = f.read().split("~~~") f.close() - - + # get the display name for a user async def display_name(self, user): try: @@ -376,16 +370,6 @@ class ollamarama: await self.client.sync_forever(timeout=30000) if __name__ == "__main__": - #load config file - 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 + bot = ollamarama() asyncio.get_event_loop().run_until_complete(bot.main())