From 568771d9b94280f1cb47aae863e8faf168eb052b Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 6 Sep 2023 20:56:51 -0700 Subject: feat: :globe_with_meridians: alpaca chat template --- continuedev/src/continuedev/libs/llm/prompts/chat.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'continuedev/src') diff --git a/continuedev/src/continuedev/libs/llm/prompts/chat.py b/continuedev/src/continuedev/libs/llm/prompts/chat.py index 1329a2ff..03230499 100644 --- a/continuedev/src/continuedev/libs/llm/prompts/chat.py +++ b/continuedev/src/continuedev/libs/llm/prompts/chat.py @@ -21,6 +21,22 @@ def anthropic_template_messages(messages: List[Dict[str, str]]) -> str: return prompt +def template_alpaca_messages(msgs: List[Dict[str, str]]) -> str: + prompt = "" + + if msgs[0]["role"] == "system": + prompt += f"{msgs[0]['content']}\n" + msgs.pop(0) + + prompt += "### Instruction:\n" + for msg in msgs: + prompt += f"{msg['content']}\n" + + prompt += "### Response:\n" + + return prompt + + def llama2_template_messages(msgs: List[Dict[str, str]]) -> str: if len(msgs) == 0: return "" -- cgit v1.2.3-70-g09d2