-
Notifications
You must be signed in to change notification settings - Fork 45k
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
feat: add event dispatcher #2908
Conversation
autogpt/config/config.py
Outdated
self.event_dispatcher_enabled = os.getenv("EVENT_DISPATCHER_ENABLED", "False") | ||
self.event_dispatcher_protocol = os.getenv("EVENT_DISPATCHER_PROTOCOL") | ||
self.event_dispatcher_host = os.getenv( | ||
"EVENT_DISPATCHER_HOST", | ||
) | ||
self.event_dispatcher_endpoint = os.getenv("EVENT_DISPATCHER_ENDPOINT") | ||
self.event_dispatcher_port = os.getenv("EVENT_DISPATCHER_PORT") | ||
self.event_dispatcher_mute = os.getenv("EVENT_DISPATCHER_MUTE", "True") | ||
|
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.
Are defaults needed for the rest of these
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.
set
autogpt/event_dispatcher.py
Outdated
except Exception as e: # ensure catching all exceptions | ||
if CFG.event_dispatcher_mute == "False": | ||
print(f"Error: {e}") |
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.
Use the existing debug flag, don't have your own
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.
changed to debug flag
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #2908 +/- ##
==========================================
- Coverage 49.63% 39.99% -9.65%
==========================================
Files 64 61 -3
Lines 3022 2923 -99
Branches 505 479 -26
==========================================
- Hits 1500 1169 -331
- Misses 1402 1678 +276
+ Partials 120 76 -44
... and 33 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
@ntindle thanks for your input, I've added your requested changes. |
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly. |
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
fix merge conflicts and its gtg |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #2908 +/- ##
===========================================
- Coverage 60.11% 41.89% -18.22%
===========================================
Files 69 65 -4
Lines 3091 3055 -36
Branches 509 509
===========================================
- Hits 1858 1280 -578
- Misses 1103 1710 +607
+ Partials 130 65 -65
☔ View full report in Codecov by Sentry. |
76dae0e
to
7c9d623
Compare
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly. |
7c9d623
to
a22ed12
Compare
Hi @ntindle thanks a lot! Fixed, rebased, retested. Looking forward for the merging. |
autogpt/event_dispatcher.py
Outdated
pass # do nothing with the response | ||
except Exception as e: # ensure catching all exceptions | ||
if CFG.debug_mode: | ||
print(f"[Event Dispatcher] Error: {e}") |
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.
Use shared logging library for logging
@ntindle good point, thanks. Changed, retested and ready for review. |
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly. |
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly. |
e158836
to
81f6de7
Compare
Hi @ntindle or other maintainers, |
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
This is a mass message from the AutoGPT core team. For more details (and for infor on joining our Discord), please refer to: |
@ntindle bump, still wanna merge this? Will need a bit of conflict resolution but nothing too bad. |
Two remarks:
|
Closing this in favor of Agent Protocol implementation: |
Background
The output of AutoGPT is logged to the console and prompt. There is no possibility to directly interact with the output. The aim of the event dispatcher is to provide the possibility for sending the events to a defined endpoint. The endpoint can be any microservice or 3rd party application (which then can do further transformations, e.g. enterprise bus). The event dispatcher fires and forgets all data that is put to the console. It can be seen as the enabler for further integration in a more complex application landscape.
Note: As this is a data forwarding, a plugin does not make sense as it does not have any effect on the running instance of AutoGPT.
Changes
The change include a configuration and the event dispatcher itself. The configuration contains all information for the endpoint (protocol, port, host, endpoint) while the event dispatcher just sends the event to the defined endpoint over HTTP POST. The feature is attached to the logs.py typewriter_log method. It forwards the data if the event dispatcher is enabled. The event dispatcher catches every exception that can occur when trying to send the request. It sends the data asynchronosly over a new thread. In case of error and if it is not muted, the error is printed to the console. It never blocks the execution and flow of AutoGPT.
Documentation
The readme.md contains the configuration documentation. Inside the environments, there is a sample config as well. Further, the code is clean and also documented.
Test Plan
Tested with following scenarios:
PR Quality Checklist