parent
10668691ea
commit
41bba61410
|
@ -77,22 +77,12 @@ class Model:
|
||||||
}
|
}
|
||||||
|
|
||||||
def serialize(self, file: BinaryIO):
|
def serialize(self, file: BinaryIO):
|
||||||
file.write(b"GPTC model v4\n")
|
file.write(b"GPTC model v5\n")
|
||||||
file.write(
|
file.write(
|
||||||
json.dumps(
|
json.dumps(
|
||||||
{
|
{
|
||||||
"names": self.names,
|
"names": self.names,
|
||||||
"max_ngram_length": self.max_ngram_length,
|
"max_ngram_length": self.max_ngram_length,
|
||||||
"has_emoji": True,
|
|
||||||
# Due to an oversight in development, version 3.0.0 still
|
|
||||||
# had the code used to make emoji support optional, even
|
|
||||||
# though the `emoji` library was made a hard dependency.
|
|
||||||
# Part of this code checked whether or not the model
|
|
||||||
# supports emoji; deserialization would not work in 3.0.0
|
|
||||||
# if the model was compiled without this field. Emoji are
|
|
||||||
# always supported with 3.0.0 and newer when GPTC has been
|
|
||||||
# installed correctly, so this value should always be True.
|
|
||||||
# Related: #11
|
|
||||||
}
|
}
|
||||||
).encode("utf-8")
|
).encode("utf-8")
|
||||||
+ b"\n"
|
+ b"\n"
|
||||||
|
@ -106,7 +96,7 @@ class Model:
|
||||||
|
|
||||||
def deserialize(encoded_model: BinaryIO) -> Model:
|
def deserialize(encoded_model: BinaryIO) -> Model:
|
||||||
prefix = encoded_model.read(14)
|
prefix = encoded_model.read(14)
|
||||||
if prefix != b"GPTC model v4\n":
|
if prefix != b"GPTC model v5\n":
|
||||||
raise InvalidModelError()
|
raise InvalidModelError()
|
||||||
|
|
||||||
config_json = b""
|
config_json = b""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user