diff --git a/matrix_pygmalion_bot/ai/koboldcpp.py b/matrix_pygmalion_bot/ai/koboldcpp.py index 696ffe0..4739f9d 100644 --- a/matrix_pygmalion_bot/ai/koboldcpp.py +++ b/matrix_pygmalion_bot/ai/koboldcpp.py @@ -21,7 +21,7 @@ logger = logging.getLogger(__name__) def setup(): os.system("mkdir -p repositories && (cd repositories && git clone https://github.com/LostRuins/koboldcpp.git)") os.system("apt update && apt-get install libopenblas-dev libclblast-dev libmkl-dev") - os.system("(cd repositories/koboldcpp && make LLAMA_OPENBLAS=1 LLAMA_CLBLAST=1 && cd models && wget https://huggingface.co/concedo/pygmalion-6bv3-ggml-ggjt/resolve/main/pygmalion-6b-v3-ggml-ggjt-q4_0.bin)") + os.system("(cd repositories/koboldcpp && make LLAMA_OPENBLAS=1 && cd models && wget https://huggingface.co/concedo/pygmalion-6bv3-ggml-ggjt/resolve/main/pygmalion-6b-v3-ggml-ggjt-q4_0.bin)") #python3 koboldcpp.py models/pygmalion-6b-v3-ggml-ggjt-q4_0.bin #python3 koboldcpp.py --smartcontext models/pygmalion-6b-v3-ggml-ggjt-q4_0.bin diff --git a/matrix_pygmalion_bot/core.py b/matrix_pygmalion_bot/core.py index 403db62..9d7e78b 100644 --- a/matrix_pygmalion_bot/core.py +++ b/matrix_pygmalion_bot/core.py @@ -62,23 +62,24 @@ class Callbacks(object): chat_message = self.bot.chat_history.room(room.room_id).add(event.event_id, event.server_timestamp, room.user_name(event.sender), event.sender == self.client.user, is_command, relates_to, event.body, language, english_original_message) # parse keywords - self.bot.extra_info = {"persona": [], "scenario": [], "example_dialogue": []} - for i, keyword in enumerate(self.bot.keywords): - if re.search(keyword["regex"], event.body, flags=re.IGNORECASE): - if not 'active' in self.bot.keywords[i] or self.bot.keywords[i]['active'] < 1: - self.bot.chat_history.room(room.room_id).setFastForward(False) - self.bot.keywords[i]['active'] = int(keyword["duration"]) - logger.info(f"keyword \"{keyword['regex']}\" detected") - if 'active' in self.bot.keywords[i]: - if self.bot.keywords[i]['active'] > 0: - logger.info(f"keyword \"{keyword['regex']}\" active. (duration {self.bot.keywords[i]['active']})") - if 'example_dialogue' in keyword: - self.bot.extra_info['example_dialogue'].append(keyword['example_dialogue']) - if 'persona' in keyword: - self.bot.extra_info['persona'].append(keyword['persona']) - if 'scenario' in keyword: - self.bot.extra_info['scenario'].append(keyword['scenario']) - self.bot.keywords[i]["active"] -= 1 + if not event.body.startswith('!') and not event.body.startswith('') + self.bot.extra_info = {"persona": [], "scenario": [], "example_dialogue": []} + for i, keyword in enumerate(self.bot.keywords): + if re.search(keyword["regex"], event.body, flags=re.IGNORECASE): + if not 'active' in self.bot.keywords[i] or self.bot.keywords[i]['active'] < 1: + self.bot.chat_history.room(room.room_id).setFastForward(False) + self.bot.keywords[i]['active'] = int(keyword["duration"]) + logger.info(f"keyword \"{keyword['regex']}\" detected: \"{event.body}\"") + if 'active' in self.bot.keywords[i]: + if self.bot.keywords[i]['active'] > 0: + logger.info(f"keyword \"{keyword['regex']}\" active. (duration {self.bot.keywords[i]['active']})") + if 'example_dialogue' in keyword: + self.bot.extra_info['example_dialogue'].append(keyword['example_dialogue']) + if 'persona' in keyword: + self.bot.extra_info['persona'].append(keyword['persona']) + if 'scenario' in keyword: + self.bot.extra_info['scenario'].append(keyword['scenario']) + self.bot.keywords[i]["active"] -= 1 if self.bot.not_synced: return