mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2025-01-07 11:23:56 +01:00
gguf : handle already encoded string
This commit is contained in:
parent
8ad7cd49fb
commit
0f5e57f01d
4
gguf.py
4
gguf.py
@ -45,7 +45,7 @@ class GGUFValueType(IntEnum):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_type(val):
|
def get_type(val):
|
||||||
if isinstance(val, str):
|
if isinstance(val, str) or isinstance(val, bytes):
|
||||||
return GGUFValueType.STRING
|
return GGUFValueType.STRING
|
||||||
elif isinstance(val, list):
|
elif isinstance(val, list):
|
||||||
return GGUFValueType.ARRAY
|
return GGUFValueType.ARRAY
|
||||||
@ -143,7 +143,7 @@ class GGUFWriter:
|
|||||||
elif vtype == GGUFValueType.BOOL:
|
elif vtype == GGUFValueType.BOOL:
|
||||||
self.fout.write(struct.pack("?", val))
|
self.fout.write(struct.pack("?", val))
|
||||||
elif vtype == GGUFValueType.STRING:
|
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("<I", len(encoded_val)))
|
self.fout.write(struct.pack("<I", len(encoded_val)))
|
||||||
self.fout.write(encoded_val)
|
self.fout.write(encoded_val)
|
||||||
elif vtype == GGUFValueType.ARRAY:
|
elif vtype == GGUFValueType.ARRAY:
|
||||||
|
Loading…
Reference in New Issue
Block a user