Files
chatgpt-telegram-bot/bot/plugins/plugin.py
2023-06-17 23:39:12 +02:00

31 lines
768 B
Python

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