mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-19 13:44:57 +01:00
various improvements and new plugins
This commit is contained in:
30
bot/plugins/plugin.py
Normal file
30
bot/plugins/plugin.py
Normal 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
|
||||
Reference in New Issue
Block a user