MCPcopy Index your code
hub / github.com/abetlen/llama-cpp-python / format_baichuan2

Function format_baichuan2

llama_cpp/llama_chat_format.py:1147–1159  ·  view source on GitHub ↗
(
    messages: List[llama_types.ChatCompletionRequestMessage],
    **kwargs: Any,
)

Source from the content-addressed store, hash-verified

1145
1146@register_chat_format("baichuan-2")
1147def format_baichuan2(
1148 messages: List[llama_types.ChatCompletionRequestMessage],
1149 **kwargs: Any,
1150) -> ChatFormatterResponse:
1151 _system_template = "{system_message}"
1152 _roles = dict(user="<reserved_106>", assistant="<reserved_107>")
1153 _sep = ""
1154 system_message = _get_system_message(messages)
1155 system_message = _system_template.format(system_message=system_message)
1156 _messages = _map_roles(messages, _roles)
1157 _messages.append((_roles["assistant"], None))
1158 _prompt = _format_no_colon_single(system_message, _messages, _sep)
1159 return ChatFormatterResponse(prompt=_prompt)
1160
1161
1162@register_chat_format("baichuan")

Callers

nothing calls this directly

Calls 6

_get_system_messageFunction · 0.85
_map_rolesFunction · 0.85
_format_no_colon_singleFunction · 0.85
formatMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…