diff --git a/aiserver.py b/aiserver.py index 39fe9662..7704c742 100644 --- a/aiserver.py +++ b/aiserver.py @@ -6142,6 +6142,9 @@ def applyoutputformatting(txt, no_sentence_trimming=False): # Replace blank lines if(koboldai_vars.frmtrmblln or koboldai_vars.chatmode): txt = utils.replaceblanklines(txt) + # trim off starting new lines in replies if we're in chat mode + if koboldai_vars.chatmode and txt[0] == "\n": + txt = txt[1:] # Remove special characters if(koboldai_vars.frmtrmspch): txt = utils.removespecialchars(txt, koboldai_vars) diff --git a/utils.py b/utils.py index 15dd9307..dc738e89 100644 --- a/utils.py +++ b/utils.py @@ -92,8 +92,7 @@ def trimincompletesentence(txt): # #==================================================================# def replaceblanklines(txt): - txt = txt.replace("\n\n", "\n") - return txt + return txt.replace("\n\n", "\n") #==================================================================# # @@ -131,8 +130,8 @@ def addsentencespacing(txt, koboldai_vars): def singlelineprocessing(txt, koboldai_vars): txt = koboldai_vars.regex_sl.sub('', txt) if(len(koboldai_vars.actions) > 0): - if(len(koboldai_vars.actions[koboldai_vars.actions.get_last_key()]) > 0): - action = koboldai_vars.actions[koboldai_vars.actions.get_last_key()] + 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