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():
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

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)
# 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('<ERROR>')
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

Loading…
Cancel
Save