Skip to content

Commit 880d63b

Browse files
remove history and callbacks from module saving (#8599)
* remove history and callbacks from module saving * ruff
1 parent a756618 commit 880d63b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

dspy/primitives/module.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ def __init__(self, callbacks=None):
4848
# LM calling history of the module.
4949
self.history = []
5050

51+
def __getstate__(self):
52+
state = self.__dict__.copy()
53+
state.pop("history", None)
54+
state.pop("callbacks", None)
55+
return state
56+
57+
def __setstate__(self, state):
58+
self.__dict__.update(state)
59+
if not hasattr(self, "history"):
60+
self.history = []
61+
if not hasattr(self, "callbacks"):
62+
self.callbacks = []
63+
5164
@with_callbacks
5265
def __call__(self, *args, **kwargs):
5366
caller_modules = settings.caller_modules or []

0 commit comments

Comments
 (0)