From e4fdef932d70242d1b091269a853ff9b6db68a29 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Thu, 13 Apr 2023 16:46:21 +0200 Subject: [PATCH] postprocessing in correct order --- matrix_pygmalion_bot/ai/koboldcpp.py | 3 +-- matrix_pygmalion_bot/ai/runpod_pygmalion.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/matrix_pygmalion_bot/ai/koboldcpp.py b/matrix_pygmalion_bot/ai/koboldcpp.py index 0e849f2..afde2db 100644 --- a/matrix_pygmalion_bot/ai/koboldcpp.py +++ b/matrix_pygmalion_bot/ai/koboldcpp.py @@ -95,11 +95,10 @@ async def generate_sync( if complete_reply: complete_reply = complete_reply.removesuffix('<|endoftext|>') - complete_reply = complete_reply.replace(f"\n{bot.name}: ", " ") - complete_reply = complete_reply.replace(f"\n: ", " ") complete_reply = complete_reply.replace(f"", f"{bot.name}") complete_reply = complete_reply.replace(f"", f"You") complete_reply = complete_reply.replace(f"### Assistant", f"{bot.name}") + complete_reply = complete_reply.replace(f"\n{bot.name}: ", " ") return complete_reply.strip() else: raise ValueError(f" Timeout") diff --git a/matrix_pygmalion_bot/ai/runpod_pygmalion.py b/matrix_pygmalion_bot/ai/runpod_pygmalion.py index 4fecfcc..78fdba9 100644 --- a/matrix_pygmalion_bot/ai/runpod_pygmalion.py +++ b/matrix_pygmalion_bot/ai/runpod_pygmalion.py @@ -87,10 +87,9 @@ async def generate_sync( reply = answer[:idx].strip() else: reply = answer.removesuffix('<|endoftext|>').strip() - reply = reply.replace(f"\n{bot.name}: ", " ") - reply = reply.replace(f"\n: ", " ") reply = reply.replace(f"", f"{bot.name}") reply = reply.replace(f"", f"You") + reply = reply.replace(f"\n{bot.name}: ", " ") return reply else: err_msg = r_json["error"] if "error" in r_json else ""