NeelakshSaxena commited on
Commit
4d14417
Β·
1 Parent(s): 3fcb89e

Use tokenizer chat template for tiny prompts

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -318,8 +318,9 @@ def build_prompt(processor_obj, user_text: str) -> str:
318
  ],
319
  }
320
  ]
321
- if hasattr(processor_obj, "apply_chat_template"):
322
- return processor_obj.apply_chat_template(messages, add_generation_prompt=True)
 
323
  return f"<image>\n{user_text}"
324
 
325
 
 
318
  ],
319
  }
320
  ]
321
+ tokenizer = getattr(processor_obj, "tokenizer", None)
322
+ if tokenizer is not None and hasattr(tokenizer, "apply_chat_template"):
323
+ return tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
324
  return f"<image>\n{user_text}"
325
 
326