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

Function _map_roles

llama_cpp/llama_chat_format.py:886–899  ·  view source on GitHub ↗

Map the message roles.

(
    messages: List[llama_types.ChatCompletionRequestMessage],
    role_map: Dict[str, str],
)

Source from the content-addressed store, hash-verified

884
885
886def _map_roles(
887 messages: List[llama_types.ChatCompletionRequestMessage],
888 role_map: Dict[str, str],
889) -> List[Tuple[str, Optional[str]]]:
890 """Map the message roles."""
891 output: List[Tuple[str, Optional[str]]] = []
892 for message in messages:
893 role = message["role"]
894 if role in role_map:
895 content: str | None = (
896 message["content"] if isinstance(message["content"], str) else None
897 )
898 output.append((role_map[role], content))
899 return output
900
901
902def _format_llama2(

Callers 15

format_llama2Function · 0.85
format_llama3Function · 0.85
format_alpacaFunction · 0.85
format_qwenFunction · 0.85
formatFunction · 0.85
format_oasst_llamaFunction · 0.85
format_baichuan2Function · 0.85
format_baichuanFunction · 0.85
format_openbuddyFunction · 0.85
format_redpajama_inciteFunction · 0.85
format_snoozyFunction · 0.85
format_phindFunction · 0.85

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…