More work on substitutions

This commit is contained in:
onesome
2022-10-10 18:05:42 -05:00
parent 8b5130c21a
commit 2af27323fc
5 changed files with 327 additions and 26 deletions

View File

@@ -6146,6 +6146,18 @@ def applyoutputformatting(txt):
if(koboldai_vars.singleline or koboldai_vars.chatmode):
txt = utils.singlelineprocessing(txt, koboldai_vars)
for sub in koboldai_vars.substitutions:
if not sub["enabled"]:
continue
i = 0
while sub["trueTarget"] in txt or sub["target"] in txt:
i += 1
if i > 1000:
logger.error("[substitutions] Infinite recursion :^(")
break
txt = txt.replace(sub["trueTarget"], sub["substitution"])
txt = txt.replace(sub["target"], sub["substitution"])
return txt
#==================================================================#
@@ -8507,6 +8519,11 @@ def UI_2_phrase_bias_update(biases):
koboldai_vars.biases = biases
@socketio.on("substitution_update")
@logger.catch
def UI_2_substitutions_update(substitutions):
koboldai_vars.substitutions = substitutions
#==================================================================#
# Event triggered to rely a message