AutoGPT
AutoGPT copied to clipboard
feat: add event dispatcher
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:
- nothing set up -> nothing is received at endpoint (simple separated HTTP server script)
- set up, not enabled -> nothing is received at endpoint (simple separated HTTP server script)
- set up, enabled, muted -> HTTP script receives events
- set up, no HTTP server running, muted-> AutoGPT works normally, no error output
- set up, no HTTP server running, not muted -> error output in the console
- set up, enabled, wrong configuration, muted -> AutoGPT works normally, no error output
- set up, enabled, wrong configuration, not muted -> error output in the console
PR Quality Checklist
- [x] My pull request is atomic and focuses on a single change.
- [x] I have thoroughly tested my changes with multiple different prompts.
- [x] I have considered potential risks and mitigations for my changes.
- [x] I have documented my changes clearly and comprehensively.
- [x] I have not snuck in any "extra" small tweaks changes
Codecov Report
Patch coverage: 66.66% and project coverage change: -9.65 :warning:
Comparison is base (
45f2513) 49.63% compared to head (3529a1c) 39.99%.
:exclamation: Current head 3529a1c differs from pull request most recent head 76dae0e. Consider uploading reports for the commit 76dae0e to get more accurate results
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
| Impacted Files | Coverage Ξ | |
|---|---|---|
| autogpt/logs.py | 46.63% <33.33%> (-11.27%) |
:arrow_down: |
| autogpt/event_dispatcher.py | 64.00% <64.00%> (ΓΈ) |
|
| autogpt/config/config.py | 74.83% <100.00%> (-1.33%) |
:arrow_down: |
... 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.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
@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 Report
Patch coverage: 66.66% and project coverage change: -18.22 :warning:
Comparison is base (
aab79fd) 60.11% compared to head (76dae0e) 41.89%.
:exclamation: Current head 76dae0e differs from pull request most recent head 81f6de7. Consider uploading reports for the commit 81f6de7 to get more accurate results
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
| Impacted Files | Coverage Ξ | |
|---|---|---|
| autogpt/logs.py | 38.86% <33.33%> (-41.44%) |
:arrow_down: |
| autogpt/event_dispatcher.py | 64.00% <64.00%> (ΓΈ) |
|
| autogpt/config/config.py | 75.64% <100.00%> (-1.19%) |
:arrow_down: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Conflicts have been resolved! π A maintainer will review the pull request shortly.
Hi @ntindle thanks a lot! Fixed, rebased, retested. Looking forward for the merging.
@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 βοΈ
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| docs | β Ready (Inspect) | Visit Preview | π¬ Add feedback | Apr 30, 2023 10:46am |
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.
Hi @ntindle or other maintainers, I've rebased and pushed again everything to ensure the branch is up to date with a clean commit. Looking forward for this PR to be merged.
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. Our apologies for the ongoing delay in processing PRs. This is because we are re-architecting the AutoGPT core!
For more details (and for infor on joining our Discord), please refer to: https://github.com/Significant-Gravitas/Auto-GPT/wiki/Architecting
@ntindle bump, still wanna merge this? Will need a bit of conflict resolution but nothing too bad.
Two remarks:
- The custom
Loggerclass has been replaced by the nativeloggingmodule. The same thing can now be achieved by implementing a customHandler, just like we did with theTTSHandler. - The proposed functionality should be covered by the Agent Protocol afaik, for which support should be added soon. :)
Closing this in favor of Agent Protocol implementation:
- #5178