mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
refactor(runner): remove useless builtin capability meta actions
This commit is contained in:
@@ -5,11 +5,7 @@ import work.slhaf.partner.api.agent.factory.capability.annotation.InjectCapabili
|
||||
import work.slhaf.partner.api.agent.factory.component.annotation.AgentComponent;
|
||||
import work.slhaf.partner.core.action.entity.MetaActionInfo;
|
||||
import work.slhaf.partner.core.cognition.CognitionCapability;
|
||||
import work.slhaf.partner.core.memory.MemoryCapability;
|
||||
import work.slhaf.partner.core.perceive.PerceiveCapability;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -25,66 +21,16 @@ class BuiltinCapabilityActionProvider implements BuiltinActionProvider {
|
||||
|
||||
private final Set<String> basicTags = Set.of("Builtin MetaAction", "Agent Capability");
|
||||
|
||||
@InjectCapability
|
||||
private MemoryCapability memoryCapability;
|
||||
@InjectCapability
|
||||
private CognitionCapability cognitionCapability;
|
||||
@InjectCapability
|
||||
private PerceiveCapability perceiveCapability;
|
||||
|
||||
@Override
|
||||
public List<BuiltinActionRegistry.BuiltinActionDefinition> provideBuiltinActions() {
|
||||
return List.of(
|
||||
buildShowActivatedSlicesDefinition(),
|
||||
buildInteractionStatusDefinition(),
|
||||
buildInitiateTurnDefinition()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于展示当前已激活的记忆切片的 Builtin MetaAction
|
||||
*
|
||||
* @return 内建 MetaAction 定义数据
|
||||
*/
|
||||
private BuiltinActionRegistry.BuiltinActionDefinition buildShowActivatedSlicesDefinition() {
|
||||
Set<String> tags = new HashSet<>(basicTags);
|
||||
tags.add("Memory");
|
||||
|
||||
MetaActionInfo info = new MetaActionInfo(
|
||||
false,
|
||||
null,
|
||||
Map.of(),
|
||||
"Show memory slices content that is activated.",
|
||||
tags,
|
||||
Set.of(),
|
||||
Set.of(),
|
||||
false,
|
||||
JSONObject.of(
|
||||
"memory_slices", "Array of activated memory slices.",
|
||||
"memory_slice.unitId", "Id of the MemoryUnit which this MemorySlice belongs to.",
|
||||
"memory_slice.summary", "Summary of the MemorySlice.",
|
||||
"memory_slice.date", "Date of the MemorySlice that is created."
|
||||
)
|
||||
);
|
||||
|
||||
Function<Map<String, Object>, String> invoker = params -> {
|
||||
List<JSONObject> memorySlices = memoryCapability.getActivatedSlices().stream()
|
||||
.map(activatedSlice -> JSONObject.of(
|
||||
"unitId", activatedSlice.getUnitId(),
|
||||
"summary", activatedSlice.getSummary(),
|
||||
"date", activatedSlice.getDate().toString()
|
||||
))
|
||||
.toList();
|
||||
return JSONObject.of("memory_slices", memorySlices).toJSONString();
|
||||
};
|
||||
|
||||
return new BuiltinActionRegistry.BuiltinActionDefinition(
|
||||
createActionKey("list_activated_memory"),
|
||||
info,
|
||||
invoker
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用于发起自对话的 Builtin MetaAction
|
||||
@@ -125,38 +71,6 @@ class BuiltinCapabilityActionProvider implements BuiltinActionProvider {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于获取当前交互状态的 Builtin MetaAction
|
||||
*
|
||||
* @return 内建 MetaAction 定义数据
|
||||
*/
|
||||
private BuiltinActionRegistry.BuiltinActionDefinition buildInteractionStatusDefinition() {
|
||||
Set<String> tags = new HashSet<>(basicTags);
|
||||
tags.add("Agent Status");
|
||||
|
||||
MetaActionInfo info = new MetaActionInfo(
|
||||
false,
|
||||
null,
|
||||
Map.of(),
|
||||
"View last interaction time.",
|
||||
tags,
|
||||
Set.of(),
|
||||
Set.of(),
|
||||
false,
|
||||
JSONObject.of(
|
||||
"lastInteractTime", "Last interaction time."
|
||||
)
|
||||
);
|
||||
|
||||
Function<Map<String, Object>, String> invoker = params -> perceiveCapability.showLastInteract().atZone(ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
return new BuiltinActionRegistry.BuiltinActionDefinition(
|
||||
createActionKey("initiate_turn"),
|
||||
info,
|
||||
invoker
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createActionKey(String actionName) {
|
||||
return CAPABILITY_LOCATION + "::" + actionName;
|
||||
|
||||
Reference in New Issue
Block a user