Skip to content
This repository has been archived by the owner on Mar 30, 2024. It is now read-only.

Commit

Permalink
Add support for openchat 3.5
Browse files Browse the repository at this point in the history
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
  • Loading branch information
chenhunghan committed Nov 3, 2023
1 parent 774c24d commit abf8830
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit abf8830

Please sign in to comment.