Skip to content
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

Updated: BasePromptDriver to publish on a list of EventListner instead of structures #914

Closed
wants to merge 2 commits into from

Conversation

torabshaikh
Copy link

This PR fixes this - #643

@collindutter
Copy link
Member

collindutter commented Jul 1, 2024

Thanks for the PR @torabshaikh! I do think it's a good idea to decouple Drivers from Structures, but I don't love having to iterate over EventListeners in each place we apply this pattern.

Maybe we need an abstraction to hold EventListeners? EventDispatcher, EventPublisher, etc?


EDIT: Spoke with the team offline, we should create an EventsMixin that moves these out of Structure:

Any Drivers that currently rely on a Structure for publish_event should implement this Mixin and have their structure: Structure field removed. Tasks can continue to use their Structure to publish events.

@torabshaikh
Copy link
Author

@collindutter Just to be clear, We need to implement a new class named EventsMixin in the events module. This class will have a list of EventListener and method like add_event_listener, remove_event_listener and publish_event. Does EventsMixin needs to iterate over the list and publish on all event_listener or it needs to have a single event_listener. Do we need to remove all of these three methods from Structure or just publish_event? Then all of the drivers that right now uses Structure to publish event can use EventsMixin to do that instead.

@collindutter
Copy link
Member

We need to implement a new class named EventsMixin in the events module.

Should be added in the mixins module, but yes.

This class will have a list of EventListener and method like add_event_listener, remove_event_listener and publish_event.

Yes, good catch I forgot about those other methods.

Does EventsMixin needs to iterate over the list and publish on all event_listener or it needs to have a single event_listener

It should iterate over event_listeners, just as the methods works in Structure today.

Do we need to remove all of these three methods from Structure or just publish_event?

Yes, remove the methods and field from Structure, and add EventsMixin to Structure.

Then all of the drivers that right now uses Structure to publish event can use EventsMixin to do that instead.

Yes.

Finally: this method should change to set self.prompt_driver.event_listeners instead of self.prompt_driver.structure.

@collindutter collindutter mentioned this pull request Jul 15, 2024
1 task
@collindutter
Copy link
Member

@torabshaikh thanks for starting this work! Some issues in Discord bumped up the urgency of this fix so I am finishing it up here: #984.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants