|
from .Extension import Extension |
|
|
|
|
|
|
|
ext_config:dict = { |
|
"name": "remember", |
|
"arguments": { |
|
'key': 'str', |
|
'value': 'str', |
|
}, |
|
"description": "Set the memory according to the key and value. (usage in response: /#remember&topic&we are talking about ...#/)))", |
|
|
|
"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) |
|
value = arg_dict.get('value', None) |
|
if key is None: |
|
raise ValueError('记忆的键不能为空') |
|
|
|
return { |
|
'memory': {'key': key, 'value': value}, |
|
} |
|
|
|
def __init__(self, custom_config: dict): |
|
super().__init__(ext_config.copy(), custom_config) |
|
|