mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-19 13:44:57 +01:00
31 lines
786 B
Python
31 lines
786 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 specs 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, function_name, **kwargs) -> Dict:
|
|
"""
|
|
Execute the plugin and return a JSON serializable response
|
|
"""
|
|
pass
|