From fa0b0b10ccd0bc678d01b1c0aa0a33681ece9595 Mon Sep 17 00:00:00 2001 From: teleprint-me <77757836+teleprint-me@users.noreply.github.com> Date: Sun, 12 May 2024 20:39:55 -0400 Subject: [PATCH] feat: Allow toggling verbosity --- gguf-py/scripts/gguf-template.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gguf-py/scripts/gguf-template.py b/gguf-py/scripts/gguf-template.py index b29c27c74..d3757b4f3 100644 --- a/gguf-py/scripts/gguf-template.py +++ b/gguf-py/scripts/gguf-template.py @@ -24,14 +24,15 @@ logging.basicConfig(level=logging.INFO) logger = logging.getLogger("gguf-chat-template") -def get_chat_template(model_file: str) -> str: +def get_chat_template(model_file: str, verbose: bool = False) -> str: reader = GGUFReader(model_file) # Available keys logger.info("Detected model metadata!") - logger.info("Outputting available model fields:") - for key in reader.fields.keys(): - logger.info(key) + if verbose: + logger.info("Outputting available model fields:") + for key in reader.fields.keys(): + logger.info(key) # Access the 'chat_template' field directly using its key chat_template_field = reader.fields.get(Keys.Tokenizer.CHAT_TEMPLATE) @@ -103,12 +104,16 @@ def main(): action="store_true", help="Render the chat template using Jinja2", ) - + parser.add_argument( + "-v", + "--verbose", + action="store_true", + help="Output model keys", + ) args = parser.parse_args() model_file = args.model_file - chat_template = get_chat_template(model_file) - + chat_template = get_chat_template(model_file, args.verbose) display_chat_template(chat_template, render_template=args.render_template)