AutoGPT icon indicating copy to clipboard operation
AutoGPT copied to clipboard

feat: add event dispatcher

Open tanns2 opened this issue 2 years ago β€’ 17 comments

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

tanns2 avatar Apr 22 '23 11:04 tanns2

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.

codecov[bot] avatar Apr 22 '23 17:04 codecov[bot]

@ntindle thanks for your input, I've added your requested changes.

tanns2 avatar Apr 23 '23 09:04 tanns2

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

github-actions[bot] avatar Apr 24 '23 13:04 github-actions[bot]

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 24 '23 18:04 github-actions[bot]

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

github-actions[bot] avatar Apr 24 '23 22:04 github-actions[bot]

fix merge conflicts and its gtg

ntindle avatar Apr 25 '23 04:04 ntindle

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:

... and 53 files with indirect coverage changes

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Apr 25 '23 04:04 codecov[bot]

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 25 '23 06:04 github-actions[bot]

Hi @ntindle thanks a lot! Fixed, rebased, retested. Looking forward for the merging.

tanns2 avatar Apr 25 '23 06:04 tanns2

@ntindle good point, thanks. Changed, retested and ready for review.

tanns2 avatar Apr 25 '23 13:04 tanns2

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

github-actions[bot] avatar Apr 26 '23 18:04 github-actions[bot]

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

vercel[bot] avatar Apr 26 '23 18:04 vercel[bot]

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 26 '23 18:04 github-actions[bot]

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

github-actions[bot] avatar Apr 26 '23 20:04 github-actions[bot]

Conflicts have been resolved! πŸŽ‰ A maintainer will review the pull request shortly.

github-actions[bot] avatar Apr 26 '23 20:04 github-actions[bot]

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.

tanns2 avatar Apr 30 '23 10:04 tanns2

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

github-actions[bot] avatar May 01 '23 12:05 github-actions[bot]

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

p-i- avatar May 05 '23 00:05 p-i-

@ntindle bump, still wanna merge this? Will need a bit of conflict resolution but nothing too bad.

Pwuts avatar Jun 14 '23 16:06 Pwuts

Two remarks:

  1. The custom Logger class has been replaced by the native logging module. The same thing can now be achieved by implementing a custom Handler, just like we did with the TTSHandler.
  2. The proposed functionality should be covered by the Agent Protocol afaik, for which support should be added soon. :)

Pwuts avatar Sep 08 '23 13:09 Pwuts

Closing this in favor of Agent Protocol implementation:

  • #5178

Pwuts avatar Sep 08 '23 22:09 Pwuts