-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Conversation Memory Autoload #1033
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,7 @@ class Structure(ABC, EventPublisherMixin): | |
logger_level: int = field(default=logging.INFO, kw_only=True) | ||
conversation_memory: Optional[BaseConversationMemory] = field( | ||
default=Factory( | ||
lambda self: ConversationMemory(driver=self.config.conversation_memory_driver), | ||
lambda self: ConversationMemory(conversation_memory_driver=self.config.conversation_memory_driver), | ||
takes_self=True, | ||
), | ||
kw_only=True, | ||
|
@@ -96,6 +96,8 @@ def validate_rules(self, _: Attribute, rules: list[Rule]) -> None: | |
def __attrs_post_init__(self) -> None: | ||
if self.conversation_memory is not None: | ||
self.conversation_memory.structure = self | ||
if self.conversation_memory.autoload: | ||
self.conversation_memory.load() | ||
Comment on lines
+99
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feels to me like this autoloading decision should be made from within the conversation memory class. Like either in the Also, won't |
||
|
||
self.config.structure = self | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the strucuture just set the driver rather than setting the structure itself? also why the
hasattr
? should it just default toNone
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern is easier to apply to other areas of the framework (tasks) if the Structure sets itself.
init=False
because we don't want users to set the Structure, it should only be done by the Structure itself.