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

Function format_chatglm3

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

Source from the content-addressed store, hash-verified

1379
1380@register_chat_format("chatglm3")
1381def format_chatglm3(
1382 messages: List[llama_types.ChatCompletionRequestMessage],
1383 **kwargs: Any,
1384) -> ChatFormatterResponse:
1385 system_template = """<|system|>
1386{system_message}"""
1387 system_message = _get_system_message(messages)
1388 system_message = system_template.format(system_message=system_message)
1389 _roles = dict(user="<|user|>", assistant="<|assistant|>")
1390 _sep = "</s>"
1391 _messages = _map_roles(messages, _roles)
1392 _messages.append((_roles["assistant"], None))
1393 _prompt = _format_chatglm3(system_message, _messages, _sep)
1394 return ChatFormatterResponse(prompt=_prompt, stop=_sep)
1395
1396
1397@register_chat_format("openchat")

Callers

nothing calls this directly

Calls 6

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