Skip to content

Commit

Permalink
Merge branch 'master' into wolfram
Browse files Browse the repository at this point in the history
  • Loading branch information
ntindle authored May 20, 2023
2 parents 781c8fc + 3d1546a commit f7bef74
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 46 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-plugin-installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
- name: Install and run different plugins
run: |
set -euo pipefail
plugins_to_test=("AutoGPTTwitter AutoGPTEmailPlugin AutoGPTSceneXPlugin AutoGPTBingSearch AutoGPTNewsSearch AutoGPTWikipediaSearch AutoGPTApiTools AutoGPTRandomValues AutoGPTSpacePlugin AutoGPTBaiduSearch AutoGPTBluesky")
plugins_to_test=("AutoGPTTwitter AutoGPTEmailPlugin AutoGPTSceneXPlugin AutoGPTBingSearch AutoGPTNewsSearch AutoGPTWikipediaSearch AutoGPTApiTools AutoGPTRandomValues AutoGPTSpacePlugin AutoGPTBaiduSearch AutoGPTBluesky PlannerPlugin")
for plugin in $plugins_to_test; do
kurtosis run github.com/kurtosis-tech/autogpt-package '{"OPENAI_API_KEY": "test", "ALLOWLISTED_PLUGINS": '\"$plugin\"', "__plugin_branch_to_use": '\"${{ github.head_ref}}\"', "__plugin_repo_to_use":'\"${{ github.event.pull_request.head.repo.full_name }}\"'}'
kurtosis run github.com/kurtosis-tech/autogpt-package '{"OPENAI_API_KEY": "test", "ALLOWLISTED_PLUGINS": '\"$plugin\"', "__skip_env_vars_validation": "True", "__skip_env_vars_default_values_set": "True", "__plugin_branch_to_use": '\"${{ github.head_ref}}\"', "__plugin_repo_to_use":'\"${{ github.event.pull_request.head.repo.full_name }}\"'}'
done
62 changes: 33 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
# Auto-GPT-Plugins

> ⚠️💀 **WARNING** 💀⚠️:
> Review the code of any plugin you use thoroughly, as plugins can execute any Python code, potentially leading to malicious activities, such as stealing your API keys.
> Always examine the code of any plugin you use thoroughly, as plugins can execute any Python code, leading to potential malicious activities such as stealing your API keys.
> ⚙️ **WORK IN PROGRESS** ⚙️:
> The plugin api is not yet stabilized. If you are coding a plugin, expect it to change in the next few versions.
> The plugin API is still being refined. If you are developing a plugin, expect changes in the upcoming versions.
## Installation

**_⚠️This is a work in progress⚠️_**

Follow these steps to configure the Auto-GPT Plugins:
Here are the steps to configure Auto-GPT Plugins:

1. **Install Auto-GPT**

If you haven't already, follow the installation instructions provided by [Auto-GPT](https://github.com/Significant-Gravitas/Auto-GPT) to install it.
If you haven't done so, follow the installation instructions given by [Auto-GPT](https://github.com/Significant-Gravitas/Auto-GPT) to install it.

1. **Run the following to pull the plugins folder down from the `root` of `Auto-GPT` directory**
1. **Download the plugins folder from the `root` of `Auto-GPT` directory**

To download it directly from your Auto-GPT directory, you can run this command on Linux or MacOS:

```bash
curl -L -o ./plugins/Auto-GPT-Plugins.zip https://github.com/Significant-Gravitas/Auto-GPT-Plugins/archive/refs/heads/master.zip
```

In PowerShell:
Or in PowerShell:

```pwsh
Invoke-WebRequest -Uri "https://github.com/Significant-Gravitas/Auto-GPT-Plugins/archive/refs/heads/master.zip" -OutFile "./plugins/Auto-GPT-Plugins.zip"
```

1. **Run the dependency install script for plugins**
You can run it with either:
1. **Execute the dependency install script for plugins**

This can be run via:

Linux or MacOS:

```bash
Expand All @@ -54,9 +56,9 @@ Follow these steps to configure the Auto-GPT Plugins:
> For interactionless use, set `ALLOWLISTED_PLUGINS=example-plugin1,example-plugin2,example-plugin3` in your `.env`
There are two kinds of plugins: **first party** and **third party**. First-party plugins are included in this repo and are installed by default along with other plugins when the plugin platform is installed. Third-party plugins need to be added individually. Use first-party plugins for plugins you expect others to use and want, and third-party for things specific to you. **You can see all the plugins and their contributors on this [directory](https://autoplugins.vercel.app/).**
There are two categories of plugins: **first party** and **third party**. First-party plugins are included in this repo and are installed by default when the plugin platform is installed. Third-party plugins need to be added individually. Use first-party plugins for widely-used plugins, and third-party for your specific needs. **You can view all the plugins and their contributors on this [directory](https://autoplugins.vercel.app/).**
If you built a plugin and it's not on the directory yet simply make a PR to this [repo](https://github.com/dylanintech/autoplugins) by adding your plugin to the `data` array in `plugins.tsx`.
If you've built a plugin and it's not listed in the directory, you can make a PR to this [repo](https://github.com/dylanintech/autoplugins) by adding your plugin to the `data` array in `plugins.tsx`.
You can also see the plugins here:
Expand All @@ -69,10 +71,11 @@ You can also see the plugins here:
| Bluesky | Enables Auto-GPT to retrieve posts from Bluesky and create new posts. | [autogpt_plugins/bluesky](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/tree/master/src/autogpt_plugins/bluesky)|
| Email | Revolutionize email management with the Auto-GPT Email Plugin, leveraging AI to automate drafting and intelligent replies. | [autogpt_plugins/email](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/tree/master/src/autogpt_plugins/email) |
| News Search | This search plugin integrates News Articles searches, using the NewsAPI aggregator into Auto-GPT. | [autogpt_plugins/news_search](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/tree/master/src/autogpt_plugins/news_search) |
| Planner | Simple Task Planner Module for Auto-GPT | [autogpt_plugins/planner](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/blob/master/src/autogpt_plugins/planner/) |
| Random Values | Enable Auto-GPT to generate various random numbers and strings. | [autogpt_plugins/random_values](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/tree/master/src/autogpt_plugins/random_values) |
| SceneX | Explore image storytelling beyond pixels with the Auto-GPT SceneX Plugin. | [autogpt_plugins/scenex](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/tree/master/src/autogpt_plugins/scenex) |
| Twitter | Auto-GPT is capable of retrieving Twitter posts and other related content by accessing the Twitter platform via the v1.1 API using Tweepy. | [autogpt_plugins/twitter](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/tree/master/src/autogpt_plugins/twitter) |
| Telegram | A smoothly working Telegram bot that gives you all the messages you would normally get through the Terminal. | [autogpt_plugins/telegram](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/tree/master/src/autogpt_plugins/telegram) |
| Twitter | Auto-GPT is capable of retrieving Twitter posts and other related content by accessing the Twitter platform via the v1.1 API using Tweepy. | [autogpt_plugins/twitter](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/tree/master/src/autogpt_plugins/twitter) |
| Wikipedia Search | This allows Auto-GPT to use Wikipedia directly. | [autogpt_plugins/wikipedia_search](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/tree/master/src/autogpt_plugins/wikipedia_search) |
| WolframAlpha Search | This allows AutoGPT to use WolframAlpha directly. | [autogpt_plugins/wolframalpha_search](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/tree/master/src/autogpt_plugins/wolframalpha_search)|
Expand All @@ -93,7 +96,8 @@ Some third-party plugins have been created by contributors that are not included
| Mastodon | Simple Mastodon plugin to send toots through a Mastodon account | [ppetermann/AutoGPTMastodonPlugin](https://github.com/ppetermann/AutoGPTMastodonPlugin)|
| MetaTrader | Connect your MetaTrader Account to Auto-GPT. | [isaiahbjork/Auto-GPT-MetaTrader-Plugin](https://github.com/isaiahbjork/Auto-GPT-MetaTrader-Plugin) |
| Notion | Notion plugin for Auto-GPT. | [doutv/Auto-GPT-Notion](https://github.com/doutv/Auto-GPT-Notion) |
| Spoonacular | Find recipe insiprations using Auto-GPT | [minfenglu/Auto-GPT-Spoonacular-Plugin](https://github.com/minfenglu/Auto-GPT-Spoonacular-Plugin)|
| Slack | This plugin allows to receive commands and send messages to slack channels | [adithya77/Auto-GPT-slack-plugin](https://github.com/adithya77/Auto-GPT-slack-plugin)
| Spoonacular | Find recipe insiprations using Auto-GPT | [minfenglu/Auto-GPT-Spoonacular-Plugin](https://github.com/minfenglu/Auto-GPT-Spoonacular-Plugin)
| System Information | This plugin adds an extra line to the prompt, serving as a hint for the AI to use shell commands likely supported by the current system. By incorporating this plugin, you can ensure that the AI model provides more accurate and system-specific shell commands, improving its overall performance and usefulness. | [hdkiller/Auto-GPT-SystemInfo](https://github.com/hdkiller/Auto-GPT-SystemInfo) |
| TiDB Serverless | Connect your TiDB Serverless database to Auto-GPT, enable get query results from database | [pingcap/Auto-GPT-TiDB-Serverless-Plugin](https://github.com/pingcap/Auto-GPT-TiDB-Serverless-Plugin)
| Todoist-Plugin | Allow Auto-GPT to programatically interact with yor Todoist to create, update, and manage your Todoist | [danikhan632/Auto-GPT-Todoist-Plugin](https://github.com/danikhan632/Auto-GPT-Todoist-Plugin) |
Expand All @@ -111,11 +115,11 @@ For interactionless use, set:
`ALLOWLISTED_PLUGINS=example-plugin1,example-plugin2,etc` in your `.env` file to allow plugins to load without prompting.
`DENYLISTED_PLUGINS=example-plugin1,example-plugin2,etc` in your `.env` file to block plugins from loading without prompting.
## Making a plugin
## Creating a Plugin
Creating a plugin is a rewarding experience! You can choose between first-party or third-party plugins. First-party plugins are included in this repo and are installed by default along with other plugins when the plugin platform is installed. Third-party plugins need to be added individually. Use first-party plugins for plugins you expect others to use and want, and third-party for things specific to you.
### First Party How-To
### First Party Plugins How-To
1. Clone the plugins repo
1. Follow the structure of the other plugins, implementing the plugin interface as required
Expand All @@ -126,26 +130,26 @@ Creating a plugin is a rewarding experience! You can choose between first-party
1. Add your plugin to the [plugin installation integration test](.github/workflows/test-plugin-installation.yml)
1. Make a PR back to this repo!
### Third Party How-To
### Third Party Plugins How-To
1. Clone [the third party template](https://github.com/Significant-Gravitas/Auto-GPT-Plugin-Template)
1. Follow the instructions in the [third party template readme](https://github.com/Significant-Gravitas/Auto-GPT-Plugin-Template)
1. Clone [the third party template](https://github.com/Significant-Gravitas/Auto-GPT-Plugin-Template).
1. Follow the instructions in the [third party template readme](https://github.com/Significant-Gravitas/Auto-GPT-Plugin-Template).
### Migrating Third Party to First Party
> Thanks for contributing a plugin to the project!
We appreciate your contribution of a plugin to the project!
1. Clone this repo.
1. Make a folder for your plugin under `src/autogpt_plugins`. Name it a simple descriptive name such as `notion`, `twitter`, or `web_ui`.
1. Take the files from your third-party plugin located at `src/auto_gpt_plugin_template` and add them into the folder you created
1. Add your readme from your third-party plugin to the folder you created
1. Add your plugin to the root readme with a description and a link to your plugin-specific readme
1. Add your plugin's Python package requirements to `requirements.txt`
1. Add tests to get your plugin to 80% code coverage
1. Add your name to the [codeowners](.github/CODEOWNERS) file
1. Add your plugin to the [Readme](README.md)
1. Make a PR back to this repo!
1. Clone this repository.
1. Make a folder for your plugin under `src/autogpt_plugins`. Use a simple descriptive name such as `notion`, `twitter`, or `web_ui`.
1. Add the files from your third-party plugin located at `src/auto_gpt_plugin_template` into the folder you created.
1. Include your README from your third-party plugin in the folder you created.
1. Add your plugin to the root README with a description and a link to your plugin-specific README.
1. Add your plugin's Python package requirements to `requirements.txt`.
1. Add tests to get your plugin to 80% code coverage.
1. Add your name to the [codeowners](.github/CODEOWNERS) file.
1. Add your plugin to the [Readme](README.md).
1. Submit a pull request back to this repository!
## Get Help
Visit the [discord](https://discord.gg/autogpt) server for more information.
For more information, visit the [discord](https://discord.gg/autogpt) server.
6 changes: 4 additions & 2 deletions src/autogpt_plugins/email/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class AutoGPTEmailPlugin(AutoGPTPluginTemplate):
def __init__(self):
super().__init__()
self._name = "Auto-GPT-Email-Plugin"
self._version = "0.1.3"
self._description = "Auto-GPT Email Plugin: Supercharge email management."
self._version = "0.2.0"
self._description = "This plugin reads and send emails."

def post_prompt(self, prompt: PromptGenerator) -> PromptGenerator:
from .email_plugin.email_plugin import (
Expand All @@ -38,6 +38,8 @@ def post_prompt(self, prompt: PromptGenerator) -> PromptGenerator:
{
"imap_folder": "<imap_folder>",
"imap_search_command": "<imap_search_criteria_command>",
"limit": "<email_count_return_limit>",
"page": "<number_of_email_results_page>",
},
read_emails,
)
Expand Down
69 changes: 66 additions & 3 deletions src/autogpt_plugins/email/email_plugin/email_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import time
from email.header import decode_header
from email.message import EmailMessage
from bs4 import BeautifulSoup



Expand Down Expand Up @@ -103,15 +104,19 @@ def send_email_with_attachment_internal(
return f"Email went to {draft_folder}!"


def read_emails(imap_folder: str = "inbox", imap_search_command: str = "UNSEEN") -> str:
def read_emails(
imap_folder: str = "inbox", imap_search_command: str = "UNSEEN", limit: int = 5,
page: int = 1) -> str:
"""Read emails from an IMAP mailbox.
This function reads emails from a specified IMAP folder, using a given IMAP search command.
This function reads emails from a specified IMAP folder, using a given IMAP search command, limits, and page numbers.
It returns a list of emails with their details, including the sender, recipient, date, CC, subject, and message body.
Args:
imap_folder (str, optional): The name of the IMAP folder to read emails from. Defaults to "inbox".
imap_search_command (str, optional): The IMAP search command to filter emails. Defaults to "UNSEEN".
limit (int, optional): Number of email's the function should return. Defaults to 5 emails.
page (int, optional): The index of the page result the function should resturn. Defaults to 0, the first page.
Returns:
str: A list of dictionaries containing email details if there are any matching emails. Otherwise, returns
Expand Down Expand Up @@ -166,6 +171,9 @@ def read_emails(imap_folder: str = "inbox", imap_search_command: str = "UNSEEN")
pass

body = get_email_body(msg)
# Clean email body
body = clean_email_body(body)

from_address = msg["From"]
to_address = msg["To"]
date = msg["Date"]
Expand All @@ -188,7 +196,30 @@ def read_emails(imap_folder: str = "inbox", imap_search_command: str = "UNSEEN")
f"There are no Emails in your folder `{imap_folder}` "
f"when searching with imap command `{imap_search_command}`"
)
return messages

# Confirm that integer parameters are the right type
limit = int(limit)
page = int(page)

# Validate parameter values
if limit < 1:
raise ValueError("Error: The message limit should be 1 or greater")

page_count = len(messages) // limit + (len(messages) % limit > 0)

if page < 1 or page > page_count:
raise ValueError("Error: The page value references a page that is not part of the results")

# Calculate paginated indexes
start_index = len(messages) - (page * limit + 1)
end_index = start_index + limit
start_index = max(start_index, 0)

# Return paginated indexes
if start_index == end_index:
return [messages[start_index]]
else:
return messages[start_index:end_index]


def adjust_imap_folder_for_gmail(imap_folder: str, email_sender: str) -> str:
Expand Down Expand Up @@ -248,3 +279,35 @@ def split_imap_search_command(input_string):
parts = [part.strip() for part in parts]

return parts

def clean_email_body(email_body):
"""Remove formating and URL's from an email's body
Args:
email_body (str, optional): The email's body
Returns:
str: The email's body without any formating or URL's
"""

# If body is None, return an empty string
if email_body is None: email_body = ""

# Remove any HTML tags
email_body = BeautifulSoup(email_body, "html.parser")
email_body = email_body.get_text()

# Remove return characters
email_body = "".join(email_body.splitlines())

# Remove extra spaces
email_body = " ".join(email_body.split())

# Remove unicode characters
email_body = email_body.encode("ascii", "ignore")
email_body = email_body.decode("utf-8", "ignore")

# Remove any remaining URL's
email_body = re.sub(r"http\S+", "", email_body)

return email_body
Loading

0 comments on commit f7bef74

Please sign in to comment.