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

Function format_openchat

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

Source from the content-addressed store, hash-verified

1396
1397@register_chat_format("openchat")
1398def format_openchat(
1399 messages: List[llama_types.ChatCompletionRequestMessage],
1400 **kwargs: Any,
1401) -> ChatFormatterResponse:
1402 system_template = "{system_message}<|end_of_turn|>"
1403 system_message = _get_system_message(messages)
1404 system_message = system_template.format(system_message=system_message)
1405 _roles = dict(
1406 user="GPT4 Correct User: ", assistant="<|end_of_turn|>GPT4 Correct Assistant: "
1407 )
1408 _sep = "<|end_of_turn|>"
1409 _messages = _map_roles(messages, _roles)
1410 _messages.append((_roles["assistant"], None))
1411 _prompt = _format_chatml(system_message, _messages, _sep)
1412 return ChatFormatterResponse(prompt=_prompt, stop=_sep)
1413
1414
1415# Chat format for Saiga models, see more details and available models:

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…