From 47c774e8a3fc0399d0deebc44536c0291af6f74c Mon Sep 17 00:00:00 2001 From: nclok1405 <155463060+nclok1405@users.noreply.github.com> Date: Tue, 28 May 2024 00:54:54 +0900 Subject: [PATCH] Add proper warning message for decode failure --- modules/llamacpp_model.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/llamacpp_model.py b/modules/llamacpp_model.py index 2b8e67cb..8cdfbb76 100644 --- a/modules/llamacpp_model.py +++ b/modules/llamacpp_model.py @@ -118,12 +118,12 @@ class LlamaCppModel: s = "" try: s = detokenized.decode('utf-8', 'strict') - except UnicodeDecodeError: + except UnicodeDecodeError as e1: try: - logger.warning("Detokenized result can't be decoded in utf-8 charset. Fallback to latin.") + logger.warning(f"Detokenized result can't be decoded in utf-8 charset. Fallback to latin.\n {e1}") s = detokenized.decode('latin', 'strict') - except UnicodeDecodeError as e: - logger.warning("Detokenized result can't be decoded in latin charset. Will attempt to decode as utf-8 with invalid characters replaced with '?' (U+FFFD).") + except UnicodeDecodeError as e2: + logger.warning(f"Detokenized result can't be decoded in latin charset. Will attempt to decode as utf-8 with invalid characters replaced with '?' (U+FFFD).\n{e2}") s = detokenized.decode('utf-8', 'replace') return s