Remove automatic recompilation

This commit is contained in:
Samuel Sloniker 2022-05-18 15:14:08 -07:00
parent 75bae768b6
commit 4ddeefad07
2 changed files with 3 additions and 21 deletions

View File

@ -20,26 +20,9 @@ class Classifier:
"""
def __init__(self, model):
try:
model_version = model["__version__"]
except:
model_version = 1
if model_version == 3:
if model.get("__version__", 0) != 3:
raise gptc.exceptions.UnsupportedModelError(f"unsupported model version")
self.model = model
else:
# The model is an unsupported version
try:
raw_model = model["__raw__"]
except:
raise gptc.exceptions.UnsupportedModelError(
"this model is unsupported and does not contain a raw model for recompiling"
)
warnings.warn(
"model needed to be recompiled on-the-fly; please re-compile it and use the new compiled model in the future"
)
self.model = gptc.compiler.compile(raw_model)
def confidence(self, text):
"""Classify text with confidence.

View File

@ -60,6 +60,5 @@ def compile(raw_model):
model["__names__"] = names
model["__version__"] = 3
model["__raw__"] = raw_model
return model