(
messages: List[llama_types.ChatCompletionRequestMessage],
**kwargs: Any,
)
| 1438 | # https://huggingface.co/collections/google/gemma-release-65d5efbccdbb8c4202ec078b |
| 1439 | @register_chat_format("gemma") |
| 1440 | def format_gemma( |
| 1441 | messages: List[llama_types.ChatCompletionRequestMessage], |
| 1442 | **kwargs: Any, |
| 1443 | ) -> ChatFormatterResponse: |
| 1444 | system_message = _get_system_message(messages) |
| 1445 | if system_message != "": |
| 1446 | logger.debug( |
| 1447 | "`role='system'` messages are not allowed on Google's Gemma models." |
| 1448 | ) |
| 1449 | _roles = dict(user="<start_of_turn>user\n", assistant="<start_of_turn>model\n") |
| 1450 | _sep = "<end_of_turn>\n" |
| 1451 | _messages = _map_roles(messages, _roles) |
| 1452 | _messages.append((_roles["assistant"], None)) |
| 1453 | _prompt = _format_no_colon_single(system_message="", messages=_messages, sep=_sep) |
| 1454 | return ChatFormatterResponse(prompt=_prompt, stop=_sep) |
| 1455 | |
| 1456 | |
| 1457 | # Tricky chat formats that require custom chat handlers |
nothing calls this directly
no test coverage detected
searching dependent graphs…