Browse Source

don't parse error messages

master
Hendrik Langer 2 years ago
parent
commit
6f23a91970
  1. 2
      matrix_pygmalion_bot/ai/koboldcpp.py
  2. 35
      matrix_pygmalion_bot/core.py

2
matrix_pygmalion_bot/ai/koboldcpp.py

@ -21,7 +21,7 @@ logger = logging.getLogger(__name__)
def setup(): def setup():
os.system("mkdir -p repositories && (cd repositories && git clone https://github.com/LostRuins/koboldcpp.git)") 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("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 models/pygmalion-6b-v3-ggml-ggjt-q4_0.bin
#python3 koboldcpp.py --smartcontext models/pygmalion-6b-v3-ggml-ggjt-q4_0.bin #python3 koboldcpp.py --smartcontext models/pygmalion-6b-v3-ggml-ggjt-q4_0.bin

35
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) 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 # parse keywords
self.bot.extra_info = {"persona": [], "scenario": [], "example_dialogue": []} if not event.body.startswith('!') and not event.body.startswith('<ERROR>')
for i, keyword in enumerate(self.bot.keywords): self.bot.extra_info = {"persona": [], "scenario": [], "example_dialogue": []}
if re.search(keyword["regex"], event.body, flags=re.IGNORECASE): for i, keyword in enumerate(self.bot.keywords):
if not 'active' in self.bot.keywords[i] or self.bot.keywords[i]['active'] < 1: if re.search(keyword["regex"], event.body, flags=re.IGNORECASE):
self.bot.chat_history.room(room.room_id).setFastForward(False) if not 'active' in self.bot.keywords[i] or self.bot.keywords[i]['active'] < 1:
self.bot.keywords[i]['active'] = int(keyword["duration"]) self.bot.chat_history.room(room.room_id).setFastForward(False)
logger.info(f"keyword \"{keyword['regex']}\" detected") self.bot.keywords[i]['active'] = int(keyword["duration"])
if 'active' in self.bot.keywords[i]: logger.info(f"keyword \"{keyword['regex']}\" detected: \"{event.body}\"")
if self.bot.keywords[i]['active'] > 0: if 'active' in self.bot.keywords[i]:
logger.info(f"keyword \"{keyword['regex']}\" active. (duration {self.bot.keywords[i]['active']})") if self.bot.keywords[i]['active'] > 0:
if 'example_dialogue' in keyword: logger.info(f"keyword \"{keyword['regex']}\" active. (duration {self.bot.keywords[i]['active']})")
self.bot.extra_info['example_dialogue'].append(keyword['example_dialogue']) if 'example_dialogue' in keyword:
if 'persona' in keyword: self.bot.extra_info['example_dialogue'].append(keyword['example_dialogue'])
self.bot.extra_info['persona'].append(keyword['persona']) if 'persona' in keyword:
if 'scenario' in keyword: self.bot.extra_info['persona'].append(keyword['persona'])
self.bot.extra_info['scenario'].append(keyword['scenario']) if 'scenario' in keyword:
self.bot.keywords[i]["active"] -= 1 self.bot.extra_info['scenario'].append(keyword['scenario'])
self.bot.keywords[i]["active"] -= 1
if self.bot.not_synced: if self.bot.not_synced:
return return

Loading…
Cancel
Save