Skip to content

Commit

Permalink
Merge branch 'master' into api-commands
Browse files Browse the repository at this point in the history
  • Loading branch information
sidewaysthought authored Jun 2, 2023
2 parents 9ace21a + 9c15850 commit ed35dc9
Show file tree
Hide file tree
Showing 49 changed files with 2,785 additions and 240 deletions.
14 changes: 9 additions & 5 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
* @Significant-Gravitas/auto-gpt-source @Significant-Gravitas/plugins
/src/autogpt_plugins/twitter @desojo
/src/autogpt_plugins/email @riensen
/src/autogpt_plugins/api_tools @sidewaysthought
/src/autogpt_plugins/astro @sr5434
/src/autogpt_plugins/scenex @delgermurun
/src/autogpt_plugins/baidu_search @ForestLinSen
/src/autogpt_plugins/bing_search @ForestLinSen
/src/autogpt_plugins/bluesky @hermanschutte
/src/autogpt_plugins/email @riensen
/src/autogpt_plugins/news_search @PalAditya
/src/autogpt_plugins/wikipedia_search @pierluigi-failla
/src/autogpt_plugins/api_tools @sidewaysthought
/src/autogpt_plugins/random_values @sidewaysthought
/src/autogpt_plugins/scenex @delgermurun
/src/autogpt_plugins/telegram @wladastic
/src/autogpt_plugins/twitter @desojo
/src/autogpt_plugins/wikipedia_search @pierluigi-failla
/src/autogpt_plugins/wolframalpha_search @pierluigi-failla
24 changes: 24 additions & 0 deletions .github/workflows/test-plugin-installation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Test installation of plugins against the PR
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test-plugin-installation:
runs-on: ubuntu-latest
steps:
- name: Install Kurtosis
run: |
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli
- name: Install and run different plugins
run: |
set -euo pipefail
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\"', "__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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,4 @@ dmypy.json

# Mac OS Files
**/.DS_Store
/.vs
125 changes: 73 additions & 52 deletions README.md

Large diffs are not rendered by default.

29 changes: 17 additions & 12 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
black
isort
flake8
pylint
abstract-singleton
wheel
setuptools
atproto
auto_gpt_plugin_template
black
bs4
build
twine
tweepy==4.13.0
colorama
flake8
isort
newsapi-python
pandas
pylint
pytest
pytest-cov
python-lorem
auto_gpt_plugin_template
newsapi-python
python-telegram-bot
requests
requests-mock
setuptools
tweepy==4.13.0
twine
validators
pytest
pytest-cov
wheel
wolframalpha==5.0.0
5 changes: 3 additions & 2 deletions src/autogpt_plugins/api_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
"""API Tools for Autogpt."""

from typing import Any, Dict, List, Optional, Tuple, TypedDict, TypeVar

from auto_gpt_plugin_template import AutoGPTPluginTemplate
try:
from .api_tools import ApiCallCommand
except ImportError:
from api_tools import ApiCallCommand


PromptGenerator = TypeVar("PromptGenerator")

class Message(TypedDict):
"""Message type."""
role: str
content: str

Expand Down Expand Up @@ -59,7 +62,6 @@ def on_planning(
prompt (PromptGenerator): The prompt generator.
messages (List[str]): The list of messages.
"""
pass

def can_handle_post_planning(self) -> bool:
"""This method is called to check that the plugin can
Expand Down Expand Up @@ -107,7 +109,6 @@ def on_instruction(self, messages: List[str]) -> Optional[str]:
Returns:
Optional[str]: The resulting message.
"""
pass

def can_handle_post_instruction(self) -> bool:
"""This method is called to check that the plugin can
Expand Down
3 changes: 2 additions & 1 deletion src/autogpt_plugins/api_tools/api_tools.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""API Call command for Autogpt."""

import json
import requests
import re
from typing import Dict, Optional
from urllib.parse import urljoin, urlparse

from urllib.parse import urljoin
from validators import url as is_valid_url
Expand Down
3 changes: 3 additions & 0 deletions src/autogpt_plugins/api_tools/test_api_tools.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import json
import random

import pytest
import requests_mock
import unittest
try:
Expand All @@ -12,6 +14,7 @@ class TestAutoGPTAPITools(unittest.TestCase):
def setUp(self):
self.plugin_class = ApiCallCommand()

class TestAutoGPTAPITools():
# Test call methods

def test_api_call_get(self):
Expand Down
27 changes: 25 additions & 2 deletions src/autogpt_plugins/astro/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""This is the email plugin for Auto-GPT."""
from typing import Any, Dict, List, Optional, Tuple, TypeVar, TypedDict
from auto_gpt_plugin_template import AutoGPTPluginTemplate
import os
from typing import Any, Dict, List, Optional, Tuple, TypedDict, TypeVar

from auto_gpt_plugin_template import AutoGPTPluginTemplate

PromptGenerator = TypeVar("PromptGenerator")

Expand Down Expand Up @@ -224,3 +225,25 @@ def handle_chat_completion(
str: The resulting response.
"""
pass

def can_handle_text_embedding(
self, text: str
) -> bool:
return False

def handle_text_embedding(
self, text: str
) -> list:
pass

def can_handle_user_input(self, user_input: str) -> bool:
return False

def user_input(self, user_input: str) -> str:
return user_input

def can_handle_report(self) -> bool:
return False

def report(self, message: str) -> None:
pass
5 changes: 4 additions & 1 deletion src/autogpt_plugins/astro/astronauts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ def get_num_astronauts():
Returns:
int: The number of astronauts in space.
"""
#Get the data
response = requests.get("http://api.open-notify.org/astros.json")
#Convert it to JSON
data = response.json()
return data["number"]
#Extract the number and return it
return data["number"]
5 changes: 2 additions & 3 deletions src/autogpt_plugins/astro/test_astro_plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from .astronauts import (
get_num_astronauts
)
from .astronauts import get_num_astronauts


def test_astro():
assert type(get_num_astronauts())==int
32 changes: 32 additions & 0 deletions src/autogpt_plugins/baidu_search/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Auto-GPT Baidu Search Plugin

Language: [English](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/tree/master/src/autogpt_plugins/baidu_search/README.md) | [中文](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/tree/master/src/autogpt_plugins/baidu_search/README.zh.md)

This search plugin integrates Baidu search engines into Auto-GPT, complementing the existing support for Google Search and DuckDuckGo Search provided by the main repository.

## Key Features:
- Baidu Search: Perform search queries using the Baidu search engine.

## How it works
If the environment variables for the search engine (`SEARCH_ENGINE`) and the Baidu cookie (`BAIDU_COOKIE`) are set, the search engine will be set to Baidu.

## Obtaining Baidu Cookie:
1. Open the Chrome browser and search for something on Baidu.
2. Open Developer Tools (press F12 or right-click and select "Inspect").
3. Go to the "Network" tab.
4. Find the first name file in the list of network requests.
5. On the right side, find the "Cookie" header and copy all of its content(it's very long).

![Baidu Cookie](./screenshots/baidu_cookie.png)

Set the `BAIDU_COOKIE` in the `.env` file:

```
SEARCH_ENGINE=baidu
BAIDU_COOKIE=your-baidu-cookie
```

Remember to replace `your-baidu-cookie` with the actual cookie content you obtained from the Chrome Developer Tools.

## Note
In most cases, the AutoGPT bot's queries are automatically set to English. However, if you wish to search in Chinese, you can specify the language in the goals.
32 changes: 32 additions & 0 deletions src/autogpt_plugins/baidu_search/README.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Auto-GPT 百度搜索插件

语言: [English](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/tree/master/src/autogpt_plugins/baidu_search/README.md) | [中文](https://github.com/Significant-Gravitas/Auto-GPT-Plugins/tree/master/src/autogpt_plugins/baidu_search/README.zh.md)

此搜索插件将百度搜索引擎集成到 Auto-GPT 中,补充了原有的 Google 搜索和 DuckDuckGo 搜索。

## 主要功能:
- 百度搜索:使用百度搜索引擎进行搜索查询。

## 工作原理:
如果设置了搜索引擎(`SEARCH_ENGINE`)和Baidu Cookie(`BAIDU_COOKIE`)的环境变量,搜索引擎将设置为百度。

### 获取百度 Cookie:
1. 打开 Chrome 浏览器并在百度上搜索随便某个内容。
2. 打开开发者工具(按 F12 或右键单击并选择 "审查元素")。
3. 转到 "网络" 标签。
4. 在网络请求列表中找到第一个名称文件。
5. 在右侧找到 "Cookie" 并复制所有内容(很长,需要全部复制)。

![Baidu Cookie](./screenshots/baidu_cookie.png)

`.env` 文件示例:

```
SEARCH_ENGINE=baidu
BAIDU_COOKIE=your-baidu-cookie
```

请将 `your-baidu-cookie` 替换为从 Chrome 开发者工具获取的实际 Cookie 内容。

## 注意事项
在大多数情况下,AutoGPT的查询关键词会被自动设置为英文。如果你想用中文关键词搜索,你可以在goals中明确指定语言。
Loading

0 comments on commit ed35dc9

Please sign in to comment.