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

Function format

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

Source from the content-addressed store, hash-verified

1113
1114@register_chat_format("vicuna")
1115def format(
1116 messages: List[llama_types.ChatCompletionRequestMessage],
1117 **kwargs: Any,
1118) -> ChatFormatterResponse:
1119 _system_message = "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions."
1120 _roles = dict(user="USER", assistant="ASSISTANT")
1121 _sep = " "
1122 _sep2 = "</s>"
1123 system_message = _system_message
1124 _messages = _map_roles(messages, _roles)
1125 _messages.append((_roles["assistant"], None))
1126 _prompt = _format_add_colon_two(system_message, _messages, _sep, _sep2)
1127 return ChatFormatterResponse(prompt=_prompt)
1128
1129
1130@register_chat_format("oasst_llama")

Callers 1

Calls 4

_map_rolesFunction · 0.85
_format_add_colon_twoFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…