@@ -86,6 +86,7 @@ impl ModelDeploymentCard {
8686 tokenizer : Some ( TokenizerKind :: from_gguf ( gguf_file) ?) ,
8787 gen_config : None , // AFAICT there is no equivalent in a GGUF
8888 prompt_formatter : Some ( PromptFormatterArtifact :: GGUF ( gguf_file. to_path_buf ( ) ) ) ,
89+ chat_template_file : None ,
8990 prompt_context : None , // TODO - auto-detect prompt context
9091 revision : 0 ,
9192 last_published : None ,
@@ -124,6 +125,7 @@ impl ModelDeploymentCard {
124125 tokenizer : Some ( TokenizerKind :: from_repo ( repo_id) . await ?) ,
125126 gen_config : GenerationConfig :: from_repo ( repo_id) . await . ok ( ) , // optional
126127 prompt_formatter : PromptFormatterArtifact :: from_repo ( repo_id) . await ?,
128+ chat_template_file : PromptFormatterArtifact :: chat_template_from_repo ( repo_id) . await ?,
127129 prompt_context : None , // TODO - auto-detect prompt context
128130 revision : 0 ,
129131 last_published : None ,
@@ -157,6 +159,17 @@ impl PromptFormatterArtifact {
157159 . ok ( ) )
158160 }
159161
162+ pub async fn chat_template_from_repo ( repo_id : & str ) -> Result < Option < Self > > {
163+ // Some HF model (i.e. meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8)
164+ // stores the chat template as a separate file, we want to optionally store
165+ // the content if it exists and put the chat template into config as normalization
166+ let template : anyhow:: Result < Self > = Ok ( Self :: HfChatTemplate (
167+ check_for_file ( repo_id, "chat_template.jinja" ) . await ?,
168+ ) ) ;
169+ Ok ( template. with_context ( || format ! ( "unable to extract prompt format from repo {}" , repo_id) )
170+ . ok ( ) )
171+ }
172+
160173 async fn try_is_hf_repo ( repo : & str ) -> anyhow:: Result < Self > {
161174 Ok ( Self :: HfTokenizerConfigJson (
162175 check_for_file ( repo, "tokenizer_config.json" ) . await ?,
0 commit comments