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

Function format_autotokenizer

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

Source from the content-addressed store, hash-verified

768 tokenizer = AutoTokenizer.from_pretrained(pretrained_model_name_or_path) # type: ignore
769
770 def format_autotokenizer(
771 messages: List[llama_types.ChatCompletionRequestMessage],
772 **kwargs: Any,
773 ) -> ChatFormatterResponse:
774 tokenizer.use_default_system_prompt = False # type: ignore
775 prompt: str = tokenizer.apply_chat_template( # type: ignore
776 messages, tokenize=False, **kwargs
777 )
778 assert isinstance(prompt, str)
779 # Return formatted prompt and eos token by default
780 return ChatFormatterResponse(
781 prompt=prompt, stop=tokenizer.eos_token, added_special=True
782 )
783
784 return format_autotokenizer
785

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…