8000 Update llama_chat_format.py SAIGA · abetlen/llama-cpp-python@bbdb581 · GitHub
[go: up one dir, main page]

Skip to content

Commit bbdb581

Browse files
Update llama_chat_format.py SAIGA
1 parent 96a3776 commit bbdb581

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

llama_cpp/llama_chat_format.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ def _format_chatml(
169169
ret += role + "\n"
170170
return ret
171171

172+
@register_chat_format("saiga")
173+
def format_saiga(
174+
messages: List[llama_types.ChatCompletionRequestMessage],
175+
**kwargs: Any,
176+
) -> ChatFormatterResponse:
177+
system_template = """<s>system\n{system_message}"""
178+
system_message = _get_system_message(messages)
179+
system_message = system_template.format(system_message=system_message)
180+
_roles = dict(user="<s>user", assistant="<s>bot\n")
181+
_sep = "</s>"
182+
_messages = _map_roles(messages, _roles)
183+
_messages.append((_roles["assistant"], None))
184+
_prompt = _format_chatml(system_message, _messages, _sep)
185+
return ChatFormatterResponse(prompt=_prompt, stop=_sep)
172186

173187
@dataclasses.dataclass
174188
class ChatFormatterResponse:

0 commit comments

Comments
 (0)
0