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

Function format_qwen

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

Source from the content-addressed store, hash-verified

1096
1097@register_chat_format("qwen")
1098def format_qwen(
1099 messages: List[llama_types.ChatCompletionRequestMessage],
1100 **kwargs: Any,
1101) -> ChatFormatterResponse:
1102 _roles = dict(user="<|im_start|>user", assistant="<|im_start|>assistant")
1103 system_message = _get_system_message(messages) or "You are a helpful assistant."
1104 system_template = "<|im_start|>system\n{system_message}"
1105 system_message = system_template.format(system_message=system_message)
1106 _messages = _map_roles(messages, _roles)
1107 _messages.append((_roles["assistant"], None))
1108 _sep = "<|im_end|>"
1109 _prompt = _format_chatml(system_message, _messages, _sep)
1110 _sep2 = "<|endoftext|>"
1111 return ChatFormatterResponse(prompt=_prompt, stop=_sep2)
1112
1113
1114@register_chat_format("vicuna")

Callers

nothing calls this directly

Calls 6

_get_system_messageFunction · 0.85
_map_rolesFunction · 0.85
_format_chatmlFunction · 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…