From 0f5e57f01d8913457f954e9b4d1ff9b9471b375a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Yusuf=20Sar=C4=B1g=C3=B6z?= Date: Sat, 29 Jul 2023 19:56:06 +0300 Subject: [PATCH] gguf : handle already encoded string --- gguf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gguf.py b/gguf.py index e0b4b88fb..88d7e43fb 100644 --- a/gguf.py +++ b/gguf.py @@ -45,7 +45,7 @@ class GGUFValueType(IntEnum): @staticmethod def get_type(val): - if isinstance(val, str): + if isinstance(val, str) or isinstance(val, bytes): return GGUFValueType.STRING elif isinstance(val, list): return GGUFValueType.ARRAY @@ -143,7 +143,7 @@ class GGUFWriter: elif vtype == GGUFValueType.BOOL: self.fout.write(struct.pack("?", val)) elif vtype == GGUFValueType.STRING: - encoded_val = val.encode("utf8") + encoded_val = val.encode("utf8") if isinstance(val, str) else val self.fout.write(struct.pack("