From 62087514c641d2ee93b1797df3388af6d60f8c6d Mon Sep 17 00:00:00 2001 From: Andrei Betlen Date: Sat, 15 Apr 2023 11:58:19 -0400 Subject: [PATCH] Update chat prompt --- llama_cpp/llama.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llama_cpp/llama.py b/llama_cpp/llama.py index e570236..578dcb6 100644 --- a/llama_cpp/llama.py +++ b/llama_cpp/llama.py @@ -696,10 +696,12 @@ class Llama: Generated chat completion or a stream of chat completion chunks. """ stop = stop if stop is not None else [] + chat_history = "".join( + f'### {"Human" if message["role"] == "user" else "Assistant"}:{message["content"]}' for message in messages ) - PROMPT = f" \n\n### Instructions:{instructions}\n\n### Inputs:{chat_history}\n\n### Response:\nassistant: " - PROMPT_STOP = ["###", "\nuser: ", "\nassistant: ", "\nsystem: "] + PROMPT = chat_history + "### Assistant:" + PROMPT_STOP = ["### Assistant:", "### Human:", "\n"] completion_or_chunks = self( prompt=PROMPT, stop=PROMPT_STOP + stop,