add clear

This commit is contained in:
Brandon Hancock
2025-01-28 14:27:57 -05:00
parent 10b42bd0d4
commit 839f3c4142

View File

@@ -1,3 +1,5 @@
import os
from crewai.utilities.file_handler import PickleHandler
@@ -29,3 +31,10 @@ class CrewTrainingHandler(PickleHandler):
data[agent_id] = {train_iteration: new_data}
self.save(data)
def clear(self) -> None:
"""Clear the training data by removing the file or resetting its contents."""
if os.path.exists(self.file_path):
with open(self.file_path, "wb") as file:
# Overwrite with an empty dictionary
self.save({})