mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Chatmode Regex
This commit is contained in:
@@ -6475,7 +6475,7 @@ def getnewcontent(txt):
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
def applyinputformatting(txt):
|
def applyinputformatting(txt):
|
||||||
# Add sentence spacing
|
# Add sentence spacing
|
||||||
if(koboldai_vars.frmtadsnsp):
|
if(koboldai_vars.frmtadsnsp and not koboldai_vars.chatmode):
|
||||||
txt = utils.addsentencespacing(txt, koboldai_vars)
|
txt = utils.addsentencespacing(txt, koboldai_vars)
|
||||||
|
|
||||||
return txt
|
return txt
|
||||||
@@ -6511,7 +6511,9 @@ def applyoutputformatting(txt, no_sentence_trimming=False, no_single_line=False)
|
|||||||
# Single Line Mode
|
# Single Line Mode
|
||||||
if(koboldai_vars.singleline and not no_single_line):
|
if(koboldai_vars.singleline and not no_single_line):
|
||||||
txt = utils.singlelineprocessing(txt, koboldai_vars)
|
txt = utils.singlelineprocessing(txt, koboldai_vars)
|
||||||
|
# Chat Mode Trimming
|
||||||
|
if(koboldai_vars.chatmode):
|
||||||
|
txt = utils.chatmodeprocessing(txt, koboldai_vars)
|
||||||
for sub in koboldai_vars.substitutions:
|
for sub in koboldai_vars.substitutions:
|
||||||
if not sub["enabled"]:
|
if not sub["enabled"]:
|
||||||
continue
|
continue
|
||||||
|
18
utils.py
18
utils.py
@@ -147,6 +147,24 @@ def singlelineprocessing(txt, koboldai_vars):
|
|||||||
txt = txt + "\n"
|
txt = txt + "\n"
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
|
def chatmodeprocessing(txt, koboldai_vars):
|
||||||
|
chatregex = re.compile(r'%s:[.|\n|\W|\w]*'%koboldai_vars.chatname)
|
||||||
|
txt = chatregex.sub('', txt)
|
||||||
|
if(len(koboldai_vars.actions) > 0):
|
||||||
|
if(len(koboldai_vars.actions[-1]) > 0):
|
||||||
|
action = koboldai_vars.actions[-1]
|
||||||
|
lastchar = action[-1] if len(action) else ""
|
||||||
|
else:
|
||||||
|
# Last action is blank, this should never happen, but
|
||||||
|
# since it did let's bail out.
|
||||||
|
return txt
|
||||||
|
else:
|
||||||
|
action = koboldai_vars.prompt
|
||||||
|
lastchar = action[-1] if len(action) else ""
|
||||||
|
if(lastchar != "\n"):
|
||||||
|
txt = txt + "\n"
|
||||||
|
return txt
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
# Cleans string for use in file name
|
# Cleans string for use in file name
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
|
Reference in New Issue
Block a user