mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
More work on substitutions
This commit is contained in:
17
aiserver.py
17
aiserver.py
@@ -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
|
||||
|
Reference in New Issue
Block a user