Auto-GPT-Plugins icon indicating copy to clipboard operation
Auto-GPT-Plugins copied to clipboard

Reduce "command returned too much output" errors in email plugin by truncating output

Open sdelgadoc opened this issue 1 year ago • 3 comments

Motivation: As a continuation to the discussion with @riensen in PR https://github.com/Significant-Gravitas/Auto-GPT-Plugins/pull/177, this PR was created as a way to further reduce "command returned too much output" errors in the email plugin by truncating email output based on configuration settings.

Changes: Added truncate_emails function that truncates the email plugin's output based on the following requirements discussed in PR https://github.com/Significant-Gravitas/Auto-GPT-Plugins/pull/177.

We set three sensible limits:
MAX_CHARACTERS: The maximum number of characters for all emails retrieved
MAX_NUM_EMAILS: The maximum number of emails
MAX_EMAIL_CHARACTERS: The maximum length per body of each email

If MAX_CHARACTERS is breached, then we check how many emails are retrieved and set a return a smaller list
If the MAX_CHARACTERS is breached while MAX_NUM_EMAILS is not breched, then we start truncating each email which exceeds MAX_EMAIL_CHARACTERS starting with the longest one.
We also need to indicate that emails were truncated to Auto-GPT like adding

Testing: Added test to validate email truncation functionality

Future Work Consider whether to use ChatGPT API to summarize emails instead of truncating them.

sdelgadoc avatar May 29 '23 20:05 sdelgadoc

Codecov Report

Patch and project coverage have no change.

Comparison is base (808016e) 58.52% compared to head (931553e) 58.52%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #186   +/-   ##
=======================================
  Coverage   58.52%   58.52%           
=======================================
  Files          36       36           
  Lines        2122     2122           
  Branches      222      222           
=======================================
  Hits         1242     1242           
  Misses        858      858           
  Partials       22       22           

: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 May 29 '23 20:05 codecov[bot]

Sorry I got assigned to this repo. Is this ready to go?

NeonN3mesis avatar Sep 21 '23 15:09 NeonN3mesis

It is from my point of view, but I believe @riensen want additional tests added.

sdelgadoc avatar Sep 21 '23 15:09 sdelgadoc