├── requirements.txt ├── .flake8 ├── .isort.cfg ├── Makefile ├── run_pylint.py ├── .editorconfig ├── helpers.sh ├── pyproject.toml ├── .pre-commit-config.yaml ├── .coveragerc ├── helpers.bat ├── LICENSE ├── README.md ├── .sourcery.yaml ├── .gitignore ├── src └── auto_gpt_plugin_template │ └── __init__.py └── pylintrc /requirements.txt: -------------------------------------------------------------------------------- 1 | black 2 | isort 3 | flake8 4 | pylint 5 | abstract-singleton 6 | wheel 7 | setuptools 8 | build 9 | twine -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 88 3 | extend-ignore = E203 4 | exclude = 5 | .tox, 6 | __pycache__, 7 | *.pyc, 8 | .env 9 | venv/* 10 | .venv/* 11 | reports/* 12 | dist/* 13 | -------------------------------------------------------------------------------- /.isort.cfg: -------------------------------------------------------------------------------- 1 | [settings] 2 | profile = black 3 | multi_line_output = 3 4 | include_trailing_comma = true 5 | force_grid_wrap = 0 6 | use_parentheses = true 7 | ensure_newline_before_comments = true 8 | line_length = 88 9 | sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER 10 | skip = .tox,__pycache__,*.pyc,venv*/*,reports,venv,env,node_modules,.env,.venv,dist 11 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(OS),Windows_NT) 2 | os := win 3 | SCRIPT_EXT := .bat 4 | SHELL_CMD := cmd /C 5 | else 6 | os := nix 7 | SCRIPT_EXT := .sh 8 | SHELL_CMD := bash 9 | endif 10 | 11 | helpers = @$(SHELL_CMD) helpers$(SCRIPT_EXT) $1 12 | 13 | clean qa style: helpers$(SCRIPT_EXT) 14 | 15 | clean: 16 | $(call helpers,clean) 17 | 18 | qa: 19 | $(call helpers,qa) 20 | 21 | style: 22 | $(call helpers,style) 23 | 24 | .PHONY: clean qa style -------------------------------------------------------------------------------- /run_pylint.py: -------------------------------------------------------------------------------- 1 | """ 2 | https://stackoverflow.com/questions/49100806/ 3 | pylint-and-subprocess-run-returning-exit-status-28 4 | """ 5 | import subprocess 6 | 7 | cmd = " pylint src\\**\\*" 8 | try: 9 | subprocComplete = subprocess.run( 10 | cmd, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE 11 | ) 12 | print(subprocComplete.stdout.decode("utf-8")) 13 | except subprocess.CalledProcessError as err: 14 | print(err.output.decode("utf-8")) 15 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Top-most EditorConfig file 2 | root = true 3 | 4 | # Set default charset 5 | [*] 6 | charset = utf-8 7 | 8 | # Use black formatter for python files 9 | [*.py] 10 | profile = black 11 | 12 | # Set defaults for windows and batch filess 13 | [*.bat] 14 | end_of_line = crlf 15 | indent_style = space 16 | indent_size = 2 17 | 18 | # Set defaults for shell scripts 19 | [*.sh] 20 | end_of_line = lf 21 | trim_trailing_whitespace = true 22 | insert_final_newline = false 23 | 24 | # Set defaults for Makefiles 25 | [Makefile] 26 | end_of_line = lf 27 | indent_style = tab 28 | indent_size = 4 29 | trim_trailing_whitespace = true 30 | insert_final_newline = true -------------------------------------------------------------------------------- /helpers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | clean() { 6 | # Remove build artifacts and temporary files 7 | rm -rf {build,dist,__pycache__,*.egg-info,**/*.egg-info,*.pyc,**/*.pyc,reports} 2>/dev/null || true 8 | } 9 | 10 | qa() { 11 | # Run static analysis tools 12 | if command -v flake8 >/dev/null 2>&1; then 13 | flake8 . 14 | fi 15 | 16 | python run_pylint.py 17 | } 18 | 19 | style() { 20 | # Format code 21 | isort . 22 | black --exclude=".*/*(dist|venv|.venv|test-results)/*.*" . 23 | } 24 | 25 | case "$1" in 26 | clean) 27 | echo Removing build artifacts and temporary files... 28 | clean 29 | ;; 30 | qa) 31 | echo Running static analysis tools... 32 | qa 33 | ;; 34 | style) 35 | echo Running code formatters... 36 | style 37 | ;; 38 | *) 39 | echo "Usage: $0 [clean|qa|style]" 40 | exit 1 41 | ;; 42 | esac 43 | 44 | printf 'Done!\n\n' 45 | exit 0 -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["hatchling"] 3 | build-backend = "hatchling.build" 4 | 5 | [project] 6 | name = "auto_gpt_plugin_template" 7 | version = "0.0.2" 8 | authors = [ 9 | { name="Torantulino", email="34168009+BillSchumacher@users.noreply.github.com" }, 10 | ] 11 | description = "The template plugin for Auto-GPT." 12 | readme = "README.md" 13 | requires-python = ">=3.8" 14 | classifiers = [ 15 | "Programming Language :: Python :: 3", 16 | "License :: OSI Approved :: MIT License", 17 | "Operating System :: OS Independent", 18 | ] 19 | dependencies = ["abstract-singleton"] 20 | 21 | [project.urls] 22 | "Homepage" = "https://github.com/Torantulino/Auto-GPT" 23 | "Bug Tracker" = "https://github.com/Torantulino/Auto-GPT" 24 | 25 | [tool.black] 26 | line-length = 88 27 | target-version = ['py38'] 28 | include = '\.pyi?$' 29 | extend-exclude = "" 30 | 31 | [tool.isort] 32 | profile = "black" 33 | 34 | [tool.pylint.messages_control] 35 | disable = "C0330, C0326" 36 | 37 | [tool.pylint.format] 38 | max-line-length = "88" -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/sourcery-ai/sourcery 3 | rev: v1.1.0 # Get the latest tag from https://github.com/sourcery-ai/sourcery/tags 4 | hooks: 5 | - id: sourcery 6 | 7 | - repo: https://github.com/pre-commit/pre-commit-hooks 8 | rev: v0.9.2 9 | hooks: 10 | - id: check-added-large-files 11 | args: [ '--maxkb=500' ] 12 | - id: check-byte-order-marker 13 | - id: check-case-conflict 14 | - id: check-merge-conflict 15 | - id: check-symlinks 16 | - id: debug-statements 17 | 18 | - repo: local 19 | hooks: 20 | - id: isort 21 | name: isort-local 22 | entry: isort 23 | language: python 24 | types: [ python ] 25 | exclude: .+/(dist|.venv|venv|build)/.+ 26 | pass_filenames: true 27 | - id: black 28 | name: black-local 29 | entry: black 30 | language: python 31 | types: [ python ] 32 | exclude: .+/(dist|.venv|venv|build)/.+ 33 | pass_filenames: true -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [coverage:run] 2 | branch = True 3 | plugins = 4 | omit = 5 | # omit anything in a .local directory anywhere 6 | */.local/* 7 | 8 | [run] 9 | branch = True 10 | plugins = 11 | omit = 12 | # omit anything in a .local directory anywhere 13 | */.local/* 14 | 15 | [paths] 16 | source = . 17 | 18 | 19 | [report] 20 | # Regexes for lines to exclude from consideration 21 | 22 | omit = 23 | # omit anything in a .local directory anywhere 24 | */.local/* 25 | 26 | exclude_lines = 27 | # Have to re-enable the standard pragma 28 | pragma: no cover 29 | # Don't complain about missing debug-only code: 30 | def __repr__ 31 | if self\.debug 32 | 33 | # Don't complain if tests don't hit defensive assertion code: 34 | raise AssertionError 35 | raise NotImplementedError 36 | 37 | # Don't complain if non-runnable code isn't run: 38 | if 0: 39 | if __name__ == .__main__.: 40 | 41 | # Don't complain about abstract methods, they aren't run: 42 | @(abc\.)?abstractmethod 43 | 44 | ignore_errors = True 45 | -------------------------------------------------------------------------------- /helpers.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if "%1" == "clean" ( 4 | echo Removing build artifacts and temporary files... 5 | call :clean 6 | ) else if "%1" == "qa" ( 7 | echo Running static analysis tools... 8 | call :qa 9 | ) else if "%1" == "style" ( 10 | echo Running code formatters... 11 | call :style 12 | ) else ( 13 | echo Usage: %0 [clean^|qa^|style] 14 | exit /b 1 15 | ) 16 | 17 | exit /b 0 18 | 19 | :clean 20 | rem Remove build artifacts and temporary files 21 | @del /s /q build 2>nul 22 | @del /s /q dist 2>nul 23 | @del /s /q __pycache__ 2>nul 24 | @del /s /q *.egg-info 2>nul 25 | @del /s /q **\*.egg-info 2>nul 26 | @del /s /q *.pyc 2>nul 27 | @del /s /q **\*.pyc 2>nul 28 | @del /s /q reports 2>nul 29 | echo Done! 30 | exit /b 0 31 | 32 | :qa 33 | rem Run static analysis tools 34 | @flake8 . 35 | @python run_pylint.py 36 | echo Done! 37 | exit /b 0 38 | 39 | :style 40 | rem Format code 41 | @isort . 42 | @black --exclude=".*\/*(dist|venv|.venv|test-results)\/*.*" . 43 | echo Done! 44 | exit /b 0 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Toran Bruce Richards 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Auto-GPT-Plugin-Template 2 | A starting point for developing your own external plug-in for Auto-GPT 3 | 4 | ### Notes for plugin developers 5 | 6 | - If you want your plugin to live within the codebase, fork the [plugins repo](https://github.com/Significant-Gravitas/Auto-GPT-Plugins) instead. Read the notes there 7 | - For a more thorough and current guide, please refer to the [plugins repository](https://github.com/Significant-Gravitas/Auto-GPT-Plugins). 8 | - If you use this repo for your own plugin, **EDIT This README** 9 | 10 | ### How to use a plugin 11 | 12 | 1. **Clone the plugin repo** into the Auto-GPT's plugins folder 13 | 2. **Install the plugin's dependencies (if any):** 14 | Navigate to the plugin's folder in your terminal, and run the following command to install any required dependencies: 15 | 16 | ``` shell 17 | pip install -r requirements.txt 18 | ``` 19 | 4. Update your plugins_config.yaml file to enable the plugin. If you skip this step the plugin won't be loaded 20 | 21 | ```shell 22 | plugin_folder: 23 | - config: {} # Configs from the plugin README and installation instructions. 24 | - enabled: true 25 | ``` 26 | -------------------------------------------------------------------------------- /.sourcery.yaml: -------------------------------------------------------------------------------- 1 | # 🪄 This is your project's Sourcery configuration file. 2 | 3 | # You can use it to get Sourcery working in the way you want, such as 4 | # ignoring specific refactorings, skipping directories in your project, 5 | # or writing custom rules. 6 | 7 | # 📚 For a complete reference to this file, see the documentation at 8 | # https://docs.sourcery.ai/Configuration/Project-Settings/ 9 | 10 | # This file was auto-generated by Sourcery on 2023-02-25 at 21:07. 11 | 12 | version: '1' # The schema version of this config file 13 | 14 | ignore: # A list of paths or files which Sourcery will ignore. 15 | - .git 16 | - venv 17 | - .venv 18 | - build 19 | - dist 20 | - env 21 | - .env 22 | - .tox 23 | 24 | rule_settings: 25 | enable: 26 | - default 27 | - gpsg 28 | disable: [] # A list of rule IDs Sourcery will never suggest. 29 | rule_types: 30 | - refactoring 31 | - suggestion 32 | - comment 33 | python_version: '3.9' # A string specifying the lowest Python version your project supports. Sourcery will not suggest refactorings requiring a higher Python version. 34 | 35 | # rules: # A list of custom rules Sourcery will include in its analysis. 36 | # - id: no-print-statements 37 | # description: Do not use print statements in the test directory. 38 | # pattern: print(...) 39 | # language: python 40 | # replacement: 41 | # condition: 42 | # explanation: 43 | # paths: 44 | # include: 45 | # - test 46 | # exclude: 47 | # - conftest.py 48 | # tests: [] 49 | # tags: [] 50 | 51 | # rule_tags: {} # Additional rule tags. 52 | 53 | # metrics: 54 | # quality_threshold: 25.0 55 | 56 | # github: 57 | # labels: [] 58 | # ignore_labels: 59 | # - sourcery-ignore 60 | # request_review: author 61 | # sourcery_branch: sourcery/{base_branch} 62 | 63 | # clone_detection: 64 | # min_lines: 3 65 | # min_duplicates: 2 66 | # identical_clones_only: false 67 | 68 | # proxy: 69 | # url: 70 | # ssl_certs_file: 71 | # no_ssl_verify: false 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /src/auto_gpt_plugin_template/__init__.py: -------------------------------------------------------------------------------- 1 | """This is a template for Auto-GPT plugins.""" 2 | import abc 3 | from typing import Any, Dict, List, Optional, Tuple, TypeVar, TypedDict 4 | 5 | from abstract_singleton import AbstractSingleton, Singleton 6 | 7 | PromptGenerator = TypeVar("PromptGenerator") 8 | 9 | 10 | class Message(TypedDict): 11 | role: str 12 | content: str 13 | 14 | 15 | class AutoGPTPluginTemplate(AbstractSingleton, metaclass=Singleton): 16 | """ 17 | This is a template for Auto-GPT plugins. 18 | """ 19 | 20 | def __init__(self): 21 | super().__init__() 22 | self._name = "Auto-GPT-Plugin-Template" 23 | self._version = "0.1.0" 24 | self._description = "This is a template for Auto-GPT plugins." 25 | 26 | @abc.abstractmethod 27 | def can_handle_on_response(self) -> bool: 28 | """This method is called to check that the plugin can 29 | handle the on_response method. 30 | 31 | Returns: 32 | bool: True if the plugin can handle the on_response method.""" 33 | return False 34 | 35 | @abc.abstractmethod 36 | def on_response(self, response: str, *args, **kwargs) -> str: 37 | """This method is called when a response is received from the model.""" 38 | pass 39 | 40 | @abc.abstractmethod 41 | def can_handle_post_prompt(self) -> bool: 42 | """This method is called to check that the plugin can 43 | handle the post_prompt method. 44 | 45 | Returns: 46 | bool: True if the plugin can handle the post_prompt method.""" 47 | return False 48 | 49 | @abc.abstractmethod 50 | def post_prompt(self, prompt: PromptGenerator) -> PromptGenerator: 51 | """This method is called just after the generate_prompt is called, 52 | but actually before the prompt is generated. 53 | 54 | Args: 55 | prompt (PromptGenerator): The prompt generator. 56 | 57 | Returns: 58 | PromptGenerator: The prompt generator. 59 | """ 60 | pass 61 | 62 | @abc.abstractmethod 63 | def can_handle_on_planning(self) -> bool: 64 | """This method is called to check that the plugin can 65 | handle the on_planning method. 66 | 67 | Returns: 68 | bool: True if the plugin can handle the on_planning method.""" 69 | return False 70 | 71 | @abc.abstractmethod 72 | def on_planning( 73 | self, prompt: PromptGenerator, messages: List[Message] 74 | ) -> Optional[str]: 75 | """This method is called before the planning chat completion is done. 76 | 77 | Args: 78 | prompt (PromptGenerator): The prompt generator. 79 | messages (List[str]): The list of messages. 80 | """ 81 | pass 82 | 83 | @abc.abstractmethod 84 | def can_handle_post_planning(self) -> bool: 85 | """This method is called to check that the plugin can 86 | handle the post_planning method. 87 | 88 | Returns: 89 | bool: True if the plugin can handle the post_planning method.""" 90 | return False 91 | 92 | @abc.abstractmethod 93 | def post_planning(self, response: str) -> str: 94 | """This method is called after the planning chat completion is done. 95 | 96 | Args: 97 | response (str): The response. 98 | 99 | Returns: 100 | str: The resulting response. 101 | """ 102 | pass 103 | 104 | @abc.abstractmethod 105 | def can_handle_pre_instruction(self) -> bool: 106 | """This method is called to check that the plugin can 107 | handle the pre_instruction method. 108 | 109 | Returns: 110 | bool: True if the plugin can handle the pre_instruction method.""" 111 | return False 112 | 113 | @abc.abstractmethod 114 | def pre_instruction(self, messages: List[Message]) -> List[Message]: 115 | """This method is called before the instruction chat is done. 116 | 117 | Args: 118 | messages (List[Message]): The list of context messages. 119 | 120 | Returns: 121 | List[Message]: The resulting list of messages. 122 | """ 123 | pass 124 | 125 | @abc.abstractmethod 126 | def can_handle_on_instruction(self) -> bool: 127 | """This method is called to check that the plugin can 128 | handle the on_instruction method. 129 | 130 | Returns: 131 | bool: True if the plugin can handle the on_instruction method.""" 132 | return False 133 | 134 | @abc.abstractmethod 135 | def on_instruction(self, messages: List[Message]) -> Optional[str]: 136 | """This method is called when the instruction chat is done. 137 | 138 | Args: 139 | messages (List[Message]): The list of context messages. 140 | 141 | Returns: 142 | Optional[str]: The resulting message. 143 | """ 144 | pass 145 | 146 | @abc.abstractmethod 147 | def can_handle_post_instruction(self) -> bool: 148 | """This method is called to check that the plugin can 149 | handle the post_instruction method. 150 | 151 | Returns: 152 | bool: True if the plugin can handle the post_instruction method.""" 153 | return False 154 | 155 | @abc.abstractmethod 156 | def post_instruction(self, response: str) -> str: 157 | """This method is called after the instruction chat is done. 158 | 159 | Args: 160 | response (str): The response. 161 | 162 | Returns: 163 | str: The resulting response. 164 | """ 165 | pass 166 | 167 | @abc.abstractmethod 168 | def can_handle_pre_command(self) -> bool: 169 | """This method is called to check that the plugin can 170 | handle the pre_command method. 171 | 172 | Returns: 173 | bool: True if the plugin can handle the pre_command method.""" 174 | return False 175 | 176 | @abc.abstractmethod 177 | def pre_command( 178 | self, command_name: str, arguments: Dict[str, Any] 179 | ) -> Tuple[str, Dict[str, Any]]: 180 | """This method is called before the command is executed. 181 | 182 | Args: 183 | command_name (str): The command name. 184 | arguments (Dict[str, Any]): The arguments. 185 | 186 | Returns: 187 | Tuple[str, Dict[str, Any]]: The command name and the arguments. 188 | """ 189 | pass 190 | 191 | @abc.abstractmethod 192 | def can_handle_post_command(self) -> bool: 193 | """This method is called to check that the plugin can 194 | handle the post_command method. 195 | 196 | Returns: 197 | bool: True if the plugin can handle the post_command method.""" 198 | return False 199 | 200 | @abc.abstractmethod 201 | def post_command(self, command_name: str, response: str) -> str: 202 | """This method is called after the command is executed. 203 | 204 | Args: 205 | command_name (str): The command name. 206 | response (str): The response. 207 | 208 | Returns: 209 | str: The resulting response. 210 | """ 211 | pass 212 | 213 | @abc.abstractmethod 214 | def can_handle_chat_completion( 215 | self, messages: Dict[Any, Any], model: str, temperature: float, max_tokens: int 216 | ) -> bool: 217 | """This method is called to check that the plugin can 218 | handle the chat_completion method. 219 | 220 | Args: 221 | messages (List[Message]): The messages. 222 | model (str): The model name. 223 | temperature (float): The temperature. 224 | max_tokens (int): The max tokens. 225 | 226 | Returns: 227 | bool: True if the plugin can handle the chat_completion method.""" 228 | return False 229 | 230 | @abc.abstractmethod 231 | def handle_chat_completion( 232 | self, messages: List[Message], model: str, temperature: float, max_tokens: int 233 | ) -> str: 234 | """This method is called when the chat completion is done. 235 | 236 | Args: 237 | messages (List[Message]): The messages. 238 | model (str): The model name. 239 | temperature (float): The temperature. 240 | max_tokens (int): The max tokens. 241 | 242 | Returns: 243 | str: The resulting response. 244 | """ 245 | pass 246 | 247 | @abc.abstractmethod 248 | def can_handle_text_embedding( 249 | self, text: str 250 | ) -> bool: 251 | """This method is called to check that the plugin can 252 | handle the text_embedding method. 253 | Args: 254 | text (str): The text to be convert to embedding. 255 | Returns: 256 | bool: True if the plugin can handle the text_embedding method.""" 257 | return False 258 | 259 | @abc.abstractmethod 260 | def handle_text_embedding( 261 | self, text: str 262 | ) -> list: 263 | """This method is called when the chat completion is done. 264 | Args: 265 | text (str): The text to be convert to embedding. 266 | Returns: 267 | list: The text embedding. 268 | """ 269 | pass 270 | 271 | @abc.abstractmethod 272 | def can_handle_user_input(self, user_input: str) -> bool: 273 | """This method is called to check that the plugin can 274 | handle the user_input method. 275 | 276 | Args: 277 | user_input (str): The user input. 278 | 279 | Returns: 280 | bool: True if the plugin can handle the user_input method.""" 281 | return False 282 | 283 | @abc.abstractmethod 284 | def user_input(self, user_input: str) -> str: 285 | """This method is called to request user input to the user. 286 | 287 | Args: 288 | user_input (str): The question or prompt to ask the user. 289 | 290 | Returns: 291 | str: The user input. 292 | """ 293 | 294 | pass 295 | 296 | @abc.abstractmethod 297 | def can_handle_report(self) -> bool: 298 | """This method is called to check that the plugin can 299 | handle the report method. 300 | 301 | Returns: 302 | bool: True if the plugin can handle the report method.""" 303 | return False 304 | 305 | @abc.abstractmethod 306 | def report(self, message: str) -> None: 307 | """This method is called to report a message to the user. 308 | 309 | Args: 310 | message (str): The message to report. 311 | """ 312 | pass 313 | -------------------------------------------------------------------------------- /pylintrc: -------------------------------------------------------------------------------- 1 | # This Pylint rcfile contains a best-effort configuration to uphold the 2 | # best-practices and style described in the Google Python style guide: 3 | # https://google.github.io/styleguide/pyguide.html 4 | # 5 | # Its canonical open-source location is: 6 | # https://google.github.io/styleguide/pylintrc 7 | 8 | [MASTER] 9 | 10 | # Files or directories to be skipped. They should be base names, not paths. 11 | ignore= 12 | 13 | # Files or directories matching the regex patterns are skipped. The regex 14 | # matches against base names, not paths. 15 | ignore-patterns= 16 | 17 | # Pickle collected data for later comparisons. 18 | persistent=no 19 | 20 | # List of plugins (as comma separated values of python modules names) to load, 21 | # usually to register additional checkers. 22 | load-plugins= 23 | 24 | # Use multiple processes to speed up Pylint. 25 | jobs=4 26 | 27 | # Allow loading of arbitrary C extensions. Extensions are imported into the 28 | # active Python interpreter and may run arbitrary code. 29 | unsafe-load-any-extension=no 30 | 31 | 32 | [MESSAGES CONTROL] 33 | 34 | ignore=*.pyc 35 | # Only show warnings with the listed confidence levels. Leave empty to show 36 | # all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED 37 | confidence= 38 | 39 | # Enable the message, report, category or checker with the given id(s). You can 40 | # either give multiple identifier separated by comma (,) or put this option 41 | # multiple time (only on the command line, not in the configuration file where 42 | # it should appear only once). See also the "--disable" option for examples. 43 | #enable= 44 | 45 | # Disable the message, report, category or checker with the given id(s). You 46 | # can either give multiple identifiers separated by comma (,) or put this 47 | # option multiple times (only on the command line, not in the configuration 48 | # file where it should appear only once).You can also use "--disable=all" to 49 | # disable everything first and then reenable specific checks. For example, if 50 | # you want to run only the similarities checker, you can use "--disable=all 51 | # --enable=similarities". If you want to run only the classes checker, but have 52 | # no Warning level messages displayed, use"--disable=all --enable=classes 53 | # --disable=W" 54 | disable=abstract-method, 55 | parse-error, 56 | apply-builtin, 57 | arguments-differ, 58 | attribute-defined-outside-init, 59 | backtick, 60 | bad-option-value, 61 | basestring-builtin, 62 | buffer-builtin, 63 | c-extension-no-member, 64 | consider-using-enumerate, 65 | cmp-builtin, 66 | cmp-method, 67 | coerce-builtin, 68 | coerce-method, 69 | delslice-method, 70 | div-method, 71 | duplicate-code, 72 | eq-without-hash, 73 | execfile-builtin, 74 | file-builtin, 75 | filter-builtin-not-iterating, 76 | fixme, 77 | getslice-method, 78 | global-statement, 79 | hex-method, 80 | idiv-method, 81 | implicit-str-concat, 82 | import-error, 83 | import-self, 84 | import-star-module-level, 85 | inconsistent-return-statements, 86 | input-builtin, 87 | intern-builtin, 88 | invalid-str-codec, 89 | locally-disabled, 90 | long-builtin, 91 | long-suffix, 92 | map-builtin-not-iterating, 93 | misplaced-comparison-constant, 94 | missing-function-docstring, 95 | metaclass-assignment, 96 | next-method-called, 97 | next-method-defined, 98 | no-absolute-import, 99 | no-else-break, 100 | no-else-continue, 101 | no-else-raise, 102 | no-else-return, 103 | no-init, # added 104 | no-member, 105 | no-name-in-module, 106 | no-self-use, 107 | nonzero-method, 108 | oct-method, 109 | old-division, 110 | old-ne-operator, 111 | old-octal-literal, 112 | old-raise-syntax, 113 | parameter-unpacking, 114 | print-statement, 115 | raising-string, 116 | range-builtin-not-iterating, 117 | raw_input-builtin, 118 | rdiv-method, 119 | reduce-builtin, 120 | relative-import, 121 | reload-builtin, 122 | round-builtin, 123 | setslice-method, 124 | signature-differs, 125 | standarderror-builtin, 126 | suppressed-message, 127 | sys-max-int, 128 | too-few-public-methods, 129 | too-many-ancestors, 130 | too-many-arguments, 131 | too-many-boolean-expressions, 132 | too-many-branches, 133 | too-many-instance-attributes, 134 | too-many-locals, 135 | too-many-nested-blocks, 136 | too-many-public-methods, 137 | too-many-return-statements, 138 | too-many-statements, 139 | trailing-newlines, 140 | unichr-builtin, 141 | unicode-builtin, 142 | unnecessary-pass, 143 | unpacking-in-except, 144 | useless-else-on-loop, 145 | useless-object-inheritance, 146 | useless-suppression, 147 | using-cmp-argument, 148 | wrong-import-order, 149 | xrange-builtin, 150 | zip-builtin-not-iterating, 151 | 152 | 153 | [REPORTS] 154 | 155 | # Set the output format. Available formats are text, parseable, colorized, msvs 156 | # (visual studio) and html. You can also give a reporter class, eg 157 | # mypackage.mymodule.MyReporterClass. 158 | output-format=text 159 | 160 | # Tells whether to display a full report or only the messages 161 | reports=no 162 | 163 | # Python expression which should return a note less than 10 (10 is the highest 164 | # note). You have access to the variables errors warning, statement which 165 | # respectively contain the number of errors / warnings messages and the total 166 | # number of statements analyzed. This is used by the global evaluation report 167 | # (RP0004). 168 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) 169 | 170 | # Template used to display messages. This is a python new-style format string 171 | # used to format the message information. See doc for all details 172 | #msg-template= 173 | 174 | 175 | [BASIC] 176 | 177 | # Good variable names which should always be accepted, separated by a comma 178 | good-names=main,_ 179 | 180 | # Bad variable names which should always be refused, separated by a comma 181 | bad-names= 182 | 183 | # Colon-delimited sets of names that determine each other's naming style when 184 | # the name regexes allow several styles. 185 | name-group= 186 | 187 | # Include a hint for the correct naming format with invalid-name 188 | include-naming-hint=no 189 | 190 | # List of decorators that produce properties, such as abc.abstractproperty. Add 191 | # to this list to register other decorators that produce valid properties. 192 | property-classes=abc.abstractproperty,cached_property.cached_property,cached_property.threaded_cached_property,cached_property.cached_property_with_ttl,cached_property.threaded_cached_property_with_ttl 193 | 194 | # Regular expression matching correct function names 195 | function-rgx=^(?:(?PsetUp|tearDown|setUpModule|tearDownModule)|(?P_?[A-Z][a-zA-Z0-9]*)|(?P_?[a-z][a-z0-9_]*))$ 196 | 197 | # Regular expression matching correct variable names 198 | variable-rgx=^[a-z][a-z0-9_]*$ 199 | 200 | # Regular expression matching correct constant names 201 | const-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$ 202 | 203 | # Regular expression matching correct attribute names 204 | attr-rgx=^_{0,2}[a-z][a-z0-9_]*$ 205 | 206 | # Regular expression matching correct argument names 207 | argument-rgx=^[a-z][a-z0-9_]*$ 208 | 209 | # Regular expression matching correct class attribute names 210 | class-attribute-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$ 211 | 212 | # Regular expression matching correct inline iteration names 213 | inlinevar-rgx=^[a-z][a-z0-9_]*$ 214 | 215 | # Regular expression matching correct class names 216 | class-rgx=^_?[A-Z][a-zA-Z0-9]*$ 217 | 218 | # Regular expression matching correct module names 219 | module-rgx=^(_?[a-z][a-z0-9_]*|__init__|__main__)$ 220 | 221 | # Regular expression matching correct method names 222 | method-rgx=(?x)^(?:(?P_[a-z0-9_]+__|runTest|setUp|tearDown|setUpTestCase|tearDownTestCase|setupSelf|tearDownClass|setUpClass|(test|assert)_*[A-Z0-9][a-zA-Z0-9_]*|next)|(?P_{0,2}[A-Z][a-zA-Z0-9_]*)|(?P_{0,2}[a-z][a-z0-9_]*))$ 223 | 224 | # Regular expression which should only match function or class names that do 225 | # not require a docstring. 226 | no-docstring-rgx=(__.*__|main|test.*|.*test|.*Test)$ 227 | 228 | # Minimum line length for functions/classes that require docstrings, shorter 229 | # ones are exempt. 230 | docstring-min-length=10 231 | 232 | 233 | [TYPECHECK] 234 | 235 | # List of decorators that produce context managers, such as 236 | # contextlib.contextmanager. Add to this list to register other decorators that 237 | # produce valid context managers. 238 | contextmanager-decorators=contextlib.contextmanager,contextlib2.contextmanager 239 | 240 | # Tells whether missing members accessed in mixin class should be ignored. A 241 | # mixin class is detected if its name ends with "mixin" (case insensitive). 242 | ignore-mixin-members=yes 243 | 244 | # List of module names for which member attributes should not be checked 245 | # (useful for modules/projects where namespaces are manipulated during runtime 246 | # and thus existing member attributes cannot be deduced by static analysis. It 247 | # supports qualified module names, as well as Unix pattern matching. 248 | ignored-modules= 249 | 250 | # List of class names for which member attributes should not be checked (useful 251 | # for classes with dynamically set attributes). This supports the use of 252 | # qualified names. 253 | ignored-classes=optparse.Values,thread._local,_thread._local 254 | 255 | # List of members which are set dynamically and missed by pylint inference 256 | # system, and so shouldn't trigger E1101 when accessed. Python regular 257 | # expressions are accepted. 258 | generated-members= 259 | 260 | 261 | [FORMAT] 262 | 263 | # Maximum number of characters on a single line. 264 | max-line-length=88 265 | 266 | # TODO(https://github.com/PyCQA/pylint/issues/3352): Direct pylint to exempt 267 | # lines made too long by directives to pytype. 268 | 269 | # Regexp for a line that is allowed to be longer than the limit. 270 | ignore-long-lines=(?x)( 271 | ^\s*(\#\ )??$| 272 | ^\s*(from\s+\S+\s+)?import\s+.+$) 273 | 274 | # Allow the body of an if to be on the same line as the test if there is no 275 | # else. 276 | single-line-if-stmt=yes 277 | 278 | # Maximum number of lines in a module 279 | max-module-lines=99999 280 | 281 | # String used as indentation unit. The internal Google style guide mandates 2 282 | # spaces. Google's externaly-published style guide says 4, consistent with 283 | # PEP 8. Here, we use 2 spaces, for conformity with many open-sourced Google 284 | # projects (like TensorFlow). 285 | indent-string=' ' 286 | 287 | # Number of spaces of indent required inside a hanging or continued line. 288 | indent-after-paren=4 289 | 290 | # Expected format of line ending, e.g. empty (any line ending), LF or CRLF. 291 | expected-line-ending-format= 292 | 293 | 294 | [MISCELLANEOUS] 295 | 296 | # List of note tags to take in consideration, separated by a comma. 297 | notes=TODO 298 | 299 | 300 | [STRING] 301 | 302 | # This flag controls whether inconsistent-quotes generates a warning when the 303 | # character used as a quote delimiter is used inconsistently within a module. 304 | check-quote-consistency=yes 305 | 306 | 307 | [VARIABLES] 308 | 309 | # Tells whether we should check for unused import in __init__ files. 310 | init-import=no 311 | 312 | # A regular expression matching the name of dummy variables (i.e. expectedly 313 | # not used). 314 | dummy-variables-rgx=^\*{0,2}(_$|unused_|dummy_) 315 | 316 | # List of additional names supposed to be defined in builtins. Remember that 317 | # you should avoid to define new builtins when possible. 318 | additional-builtins= 319 | 320 | # List of strings which can identify a callback function by name. A callback 321 | # name must start or end with one of those strings. 322 | callbacks=cb_,_cb 323 | 324 | # List of qualified module names which can have objects that can redefine 325 | # builtins. 326 | redefining-builtins-modules=six,six.moves,past.builtins,future.builtins,functools 327 | 328 | 329 | [LOGGING] 330 | 331 | # Logging modules to check that the string format arguments are in logging 332 | # function parameter format 333 | logging-modules=logging,absl.logging,tensorflow.io.logging 334 | 335 | 336 | [SIMILARITIES] 337 | 338 | # Minimum lines number of a similarity. 339 | min-similarity-lines=4 340 | 341 | # Ignore comments when computing similarities. 342 | ignore-comments=yes 343 | 344 | # Ignore docstrings when computing similarities. 345 | ignore-docstrings=yes 346 | 347 | # Ignore imports when computing similarities. 348 | ignore-imports=no 349 | 350 | 351 | [SPELLING] 352 | 353 | # Spelling dictionary name. Available dictionaries: none. To make it working 354 | # install python-enchant package. 355 | spelling-dict= 356 | 357 | # List of comma separated words that should not be checked. 358 | spelling-ignore-words= 359 | 360 | # A path to a file that contains private dictionary; one word per line. 361 | spelling-private-dict-file= 362 | 363 | # Tells whether to store unknown words to indicated private dictionary in 364 | # --spelling-private-dict-file option instead of raising a message. 365 | spelling-store-unknown-words=no 366 | 367 | 368 | [IMPORTS] 369 | 370 | # Deprecated modules which should not be used, separated by a comma 371 | deprecated-modules=regsub, 372 | TERMIOS, 373 | Bastion, 374 | rexec, 375 | sets 376 | 377 | # Create a graph of every (i.e. internal and external) dependencies in the 378 | # given file (report RP0402 must not be disabled) 379 | import-graph= 380 | 381 | # Create a graph of external dependencies in the given file (report RP0402 must 382 | # not be disabled) 383 | ext-import-graph= 384 | 385 | # Create a graph of internal dependencies in the given file (report RP0402 must 386 | # not be disabled) 387 | int-import-graph= 388 | 389 | # Force import order to recognize a module as part of the standard 390 | # compatibility libraries. 391 | known-standard-library= 392 | 393 | # Force import order to recognize a module as part of a third party library. 394 | known-third-party=enchant, absl 395 | 396 | # Analyse import fallback blocks. This can be used to support both Python 2 and 397 | # 3 compatible code, which means that the block might have code that exists 398 | # only in one or another interpreter, leading to false positives when analysed. 399 | analyse-fallback-blocks=no 400 | 401 | 402 | [CLASSES] 403 | 404 | # List of method names used to declare (i.e. assign) instance attributes. 405 | defining-attr-methods=__init__, 406 | __new__, 407 | setUp 408 | 409 | # List of member names, which should be excluded from the protected access 410 | # warning. 411 | exclude-protected=_asdict, 412 | _fields, 413 | _replace, 414 | _source, 415 | _make 416 | 417 | # List of valid names for the first argument in a class method. 418 | valid-classmethod-first-arg=cls, 419 | class_ 420 | 421 | # List of valid names for the first argument in a metaclass class method. 422 | valid-metaclass-classmethod-first-arg=mcs 423 | 424 | 425 | [EXCEPTIONS] 426 | 427 | # Exceptions that will emit a warning when being caught. Defaults to 428 | # "Exception" 429 | overgeneral-exceptions=builtins.StandardError, 430 | builtins.Exception, 431 | builtins.BaseException 432 | --------------------------------------------------------------------------------