fix: fix a bug in competition metric evaluation (#407)

* fix a bug in competition metric evaluation

* fix a bug

* fix a bug in rag loading
This commit is contained in:
WinstonLiyt
2024-09-30 14:54:56 +08:00
committed by GitHub
parent 1cbaa4b15c
commit 80b392ce2f
3 changed files with 12 additions and 12 deletions
+6 -4
View File
@@ -13,13 +13,15 @@ class KnowledgeBase:
def load(self) -> None:
if self.path is not None and self.path.exists():
with self.path.open("rb") as f:
self.__dict__.update(
pickle.load(f).__dict__,
) # TODO: because we need to align with init function, we need a less hacky way to do this
loaded = pickle.load(f)
if isinstance(loaded, dict):
self.__dict__.update(loaded)
else:
self.__dict__.update(loaded.__dict__)
def dump(self) -> None:
if self.path is not None:
self.path.parent.mkdir(parents=True, exist_ok=True)
pickle.dump(self, self.path.open("wb"))
pickle.dump(self.__dict__, self.path.open("wb"))
else:
logger.warning("KnowledgeBase path is not set, dump failed.")