From efd70f3ce9e79af186d5bd5e276db962d52df29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigbj=C3=B8rn=20Skj=C3=A6ret?= Date: Thu, 9 May 2024 12:21:11 +0200 Subject: [PATCH] fail on invalid token id --- gguf-py/scripts/gguf-new-metadata.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gguf-py/scripts/gguf-new-metadata.py b/gguf-py/scripts/gguf-new-metadata.py index f2a9e8b14..63d3c5d8f 100755 --- a/gguf-py/scripts/gguf-new-metadata.py +++ b/gguf-py/scripts/gguf-new-metadata.py @@ -209,14 +209,14 @@ def main() -> None: if name not in token_names: logger.warning(f'Unknown special token "{name}", ignoring...') elif not id_string.isdecimal(): - logger.warning(f'Token ID "{id_string}" is not a valid ID, ignoring...') + raise LookupError(f'Token ID "{id_string}" is not a valid ID!') else: id_int = int(id_string) if id_int >= 0 and id_int < len(token_list): new_metadata[token_names[name]] = MetadataDetails(gguf.GGUFValueType.UINT32, id_int, f'= {token_list[id_int]}') else: - logger.warning(f'Token ID {id_int} is not within token list, ignoring...') + raise LookupError(f'Token ID {id_int} is not within token list!') if os.path.isfile(args.output) and not args.force: logger.warning('*** Warning *** Warning *** Warning **')