From 78d5a999e6bd7267b29ae7334b23b50f1066f382 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 20 Jan 2023 01:54:38 -0300 Subject: [PATCH] Improve prompt formatation --- server.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 12892fe0..3c1a0fa7 100644 --- a/server.py +++ b/server.py @@ -232,11 +232,12 @@ if args.chat or args.cai_chat: def generate_chat_prompt(text, tokens, name1, name2, context): text = clean_chat_message(text) - rows = [f"{context}\n\n"] + rows = [f"{context.strip()}\n"] i = len(history)-1 while i >= 0 and len(encode(''.join(rows), tokens)[0]) < 2048-tokens: rows.insert(1, f"{name2}: {history[i][1].strip()}\n") - rows.insert(1, f"{name1}: {history[i][0].strip()}\n") + if not (i == 0 and len(history[i][0]) == 0): + rows.insert(1, f"{name1}: {history[i][0].strip()}\n") i -= 1 rows.append(f"{name1}: {text}\n") rows.append(f"{name2}:")