feat:将relation获取变为工具
This commit is contained in:
@@ -140,7 +140,7 @@ class EmojiAction(BaseAction):
|
||||
# 存储动作信息
|
||||
await self.store_action_info(
|
||||
action_build_into_prompt=True,
|
||||
action_prompt_display=f"发送了表情包,原因:{reason}",
|
||||
action_prompt_display=f"你发送了表情包,原因:{reason}",
|
||||
action_done=True,
|
||||
)
|
||||
return True, f"成功发送表情包:{emoji_description}"
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from typing import List, Tuple, Type
|
||||
from typing import List, Tuple, Type, Any
|
||||
|
||||
# 导入新插件系统
|
||||
from src.plugin_system import BasePlugin, register_plugin, ComponentInfo
|
||||
from src.plugin_system.base.config_types import ConfigField
|
||||
from src.person_info.person_info import Person
|
||||
from src.plugin_system.base.base_tool import BaseTool, ToolParamType
|
||||
|
||||
# 导入依赖的系统组件
|
||||
from src.common.logger import get_logger
|
||||
@@ -12,6 +14,42 @@ from src.plugins.built_in.relation.relation import BuildRelationAction
|
||||
logger = get_logger("relation_actions")
|
||||
|
||||
|
||||
|
||||
class GetPersonInfoTool(BaseTool):
|
||||
"""获取用户信息"""
|
||||
|
||||
name = "get_person_info"
|
||||
description = "获取某个人的信息,包括印象,特征点,与用户的关系等等"
|
||||
parameters = [
|
||||
("person_name", ToolParamType.STRING, "需要获取信息的人的名称", True, None),
|
||||
("info_type", ToolParamType.STRING, "需要获取信息的类型", True, None),
|
||||
]
|
||||
|
||||
available_for_llm = True
|
||||
|
||||
async def execute(self, function_args: dict[str, Any]) -> dict[str, Any]:
|
||||
"""执行比较两个数的大小
|
||||
|
||||
Args:
|
||||
function_args: 工具参数
|
||||
|
||||
Returns:
|
||||
dict: 工具执行结果
|
||||
"""
|
||||
person_name: str = function_args.get("person_name") # type: ignore
|
||||
info_type: str = function_args.get("info_type") # type: ignore
|
||||
|
||||
person = Person(person_name=person_name)
|
||||
if not person:
|
||||
return {"content": f"用户 {person_name} 不存在"}
|
||||
if not person.is_known:
|
||||
return {"content": f"不认识用户 {person_name}"}
|
||||
|
||||
relation_str = await person.build_relationship(info_type=info_type)
|
||||
|
||||
return {"content": relation_str}
|
||||
|
||||
|
||||
@register_plugin
|
||||
class RelationActionsPlugin(BasePlugin):
|
||||
"""关系动作插件
|
||||
@@ -54,5 +92,6 @@ class RelationActionsPlugin(BasePlugin):
|
||||
# --- 根据配置注册组件 ---
|
||||
components = []
|
||||
components.append((BuildRelationAction.get_action_info(), BuildRelationAction))
|
||||
components.append((GetPersonInfoTool.get_tool_info(), GetPersonInfoTool))
|
||||
|
||||
return components
|
||||
|
||||
Reference in New Issue
Block a user