From abf8830e73a83038086fec29dcca80acbec68148 Mon Sep 17 00:00:00 2001 From: "Hung-Han (Henry) Chen" Date: Fri, 3 Nov 2023 14:26:39 +0200 Subject: [PATCH] Add support for openchat 3.5 Signed-off-by: Hung-Han (Henry) Chen --- main.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 6b936cd..506637e 100644 --- a/main.py +++ b/main.py @@ -370,13 +370,22 @@ async def chat_completions( assistant_start = "### Assistant:\n" user_start = "### User:\n" user_end = "\n\n" + # openchat_3.5 https://huggingface.co/openchat/openchat_3.5 + if "openchat" in body.model.lower(): + system_start = "" + system = "" + system_end = "" + assistant_start = "GPT4 Assistant: " + assistant_end = "<|end_of_turn|>" + user_start = "GPT4 User: " + user_end = "<|end_of_turn|>" user_message = next( - (message for message in body.messages if message.role == "user"), None + (message for message in reversed(body.messages) if message.role == "user"), None ) user_message_content = user_message.content if user_message else "" assistant_message = next( - (message for message in body.messages if message.role == "assistant"), None + (message for message in reversed(body.messages) if message.role == "assistant"), None ) assistant_message_content = ( f"{assistant_start}{assistant_message.content}{assistant_end}"