(
messages: List[llama_types.ChatCompletionRequestMessage],
**kwargs: Any,
)
| 1065 | # https://github.com/meta-llama/llama3/blob/main/llama/tokenizer.py#L202-L229 |
| 1066 | @register_chat_format("llama-3") |
| 1067 | def format_llama3( |
| 1068 | messages: List[llama_types.ChatCompletionRequestMessage], |
| 1069 | **kwargs: Any, |
| 1070 | ) -> ChatFormatterResponse: |
| 1071 | _roles = dict( |
| 1072 | system="<|start_header_id|>system<|end_header_id|>\n\n", |
| 1073 | user="<|start_header_id|>user<|end_header_id|>\n\n", |
| 1074 | assistant="<|start_header_id|>assistant<|end_header_id|>\n\n", |
| 1075 | ) |
| 1076 | _sep = "<|eot_id|>" |
| 1077 | _messages = _map_roles(messages, _roles) |
| 1078 | _messages.append((_roles["assistant"], None)) |
| 1079 | _prompt = _format_no_colon_single("", _messages, _sep) |
| 1080 | return ChatFormatterResponse(prompt=_prompt, stop=_sep) |
| 1081 | |
| 1082 | |
| 1083 | @register_chat_format("alpaca") |
nothing calls this directly
no test coverage detected
searching dependent graphs…