Skip to content

Commit efd70f3

Browse files
authored
fail on invalid token id
1 parent 144d99a commit efd70f3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

gguf-py/scripts/gguf-new-metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@ def main() -> None:
209209
if name not in token_names:
210210
logger.warning(f'Unknown special token "{name}", ignoring...')
211211
elif not id_string.isdecimal():
212-
logger.warning(f'Token ID "{id_string}" is not a valid ID, ignoring...')
212+
raise LookupError(f'Token ID "{id_string}" is not a valid ID!')
213213
else:
214214
id_int = int(id_string)
215215

216216
if id_int >= 0 and id_int < len(token_list):
217217
new_metadata[token_names[name]] = MetadataDetails(gguf.GGUFValueType.UINT32, id_int, f'= {token_list[id_int]}')
218218
else:
219-
logger.warning(f'Token ID {id_int} is not within token list, ignoring...')
219+
raise LookupError(f'Token ID {id_int} is not within token list!')
220220

221221
if os.path.isfile(args.output) and not args.force:
222222
logger.warning('*** Warning *** Warning *** Warning **')

0 commit comments

Comments
 (0)