|
from .Extension import Extension |
|
|
|
|
|
|
|
ext_config:dict = { |
|
"name": "forget", |
|
"arguments": { |
|
'key': 'str', |
|
'value': 'str', |
|
}, |
|
"description": "Delete the memory according to the key. (usage in response: /#forget&topic#/)))", |
|
|
|
"refer_word": [], |
|
|
|
"max_call_times_per_msg": 5, |
|
|
|
"author": "KroMiose", |
|
|
|
"version": "0.0.1", |
|
|
|
"intro": "主动遗忘模块", |
|
} |
|
|
|
class CustomExtension(Extension): |
|
async def call(self, arg_dict: dict, ctx_data: dict) -> dict: |
|
""" 当拓展被调用时执行的函数 *由拓展自行实现* |
|
|
|
参数: |
|
arg_dict: dict, 由ai解析的参数字典 {参数名: 参数值(类型为str)} |
|
""" |
|
custom_config:dict = self.get_custom_config() |
|
|
|
|
|
key = arg_dict.get('key', None) |
|
if key is None: |
|
raise ValueError('记忆的键不能为空') |
|
|
|
return { |
|
'memory': {'key': key}, |
|
} |
|
|
|
def __init__(self, custom_config: dict): |
|
super().__init__(ext_config.copy(), custom_config) |
|
|