various improvements and new plugins

This commit is contained in:
ned
2023-06-17 23:39:12 +02:00
parent c9d9c75d6c
commit 302cdc035d
11 changed files with 298 additions and 78 deletions

30
bot/plugins/plugin.py Normal file
View File

@@ -0,0 +1,30 @@
from abc import abstractmethod, ABC
from typing import Dict
class Plugin(ABC):
"""
A plugin interface which can be used to create plugins for the ChatGPT API.
"""
@abstractmethod
def get_source_name(self) -> str:
"""
Return the name of the source of the plugin.
"""
pass
@abstractmethod
def get_spec(self) -> Dict:
"""
Function spec in the form of JSON schema as specified in the OpenAI documentation:
https://platform.openai.com/docs/api-reference/chat/create#chat/create-functions
"""
pass
@abstractmethod
async def execute(self, **kwargs) -> Dict:
"""
Execute the plugin and return a JSON serializable response
"""
pass