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

Function format_tokenizer_config

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

Source from the content-addressed store, hash-verified

815 ).from_string(chat_template)
816
817 def format_tokenizer_config(
818 messages: List[llama_types.ChatCompletionRequestMessage],
819 **kwargs: Any,
820 ) -> ChatFormatterResponse:
821 # TODO: veryify this is correct
822 # Add a blank assistant message to the end of the messages to prompt the model to generate a response
823 if add_generation_prompt:
824 messages = [
825 *messages,
826 llama_types.ChatCompletionRequestAssistantMessage(
827 role="assistant", content=""
828 ),
829 ]
830 prompt = env.render(
831 messages=messages,
832 bos_token=bos_token,
833 eos_token=eos_token,
834 **kwargs,
835 )
836 return ChatFormatterResponse(
837 prompt=prompt, stop=[eos_token, bos_token], added_special=True
838 )
839
840 return format_tokenizer_config
841

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…