mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-10-29 21:50:16 +01:00
Add proper warning message for decode failure
This commit is contained in:
parent
f5ca611569
commit
47c774e8a3
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user