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

Function format_alpaca

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

Source from the content-addressed store, hash-verified

1082
1083@register_chat_format("alpaca")
1084def format_alpaca(
1085 messages: List[llama_types.ChatCompletionRequestMessage],
1086 **kwargs: Any,
1087) -> ChatFormatterResponse:
1088 _roles = dict(user="### Instruction", assistant="### Response")
1089 _sep = "\n\n"
1090 _sep2 = "</s>"
1091 system_message = _get_system_message(messages)
1092 _messages = _map_roles(messages, _roles)
1093 _prompt = _format_add_colon_two(system_message, _messages, _sep, _sep2)
1094 return ChatFormatterResponse(prompt=_prompt)
1095
1096
1097@register_chat_format("qwen")

Callers

nothing calls this directly

Calls 4

_get_system_messageFunction · 0.85
_map_rolesFunction · 0.85
_format_add_colon_twoFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…