mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
refactor(cogiaiateTurnnation): support assigning reply target in method
initiateTurn
This commit is contained in:
@@ -9,7 +9,7 @@ import java.util.concurrent.locks.Lock;
|
|||||||
@Capability("cognation")
|
@Capability("cognation")
|
||||||
public interface CognationCapability {
|
public interface CognationCapability {
|
||||||
|
|
||||||
String initiateTurn(String input);
|
String initiateTurn(String input, String target);
|
||||||
|
|
||||||
List<Message> getChatMessages();
|
List<Message> getChatMessages();
|
||||||
|
|
||||||
|
|||||||
@@ -38,8 +38,9 @@ public class CognationCore extends PartnerCore<CognationCore> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CapabilityMethod
|
@CapabilityMethod
|
||||||
public String initiateTurn(String input) {
|
public String initiateTurn(String input, String target) {
|
||||||
PartnerRunningFlowContext primaryContext = PartnerRunningFlowContext.Companion.fromSelf(input);
|
PartnerRunningFlowContext primaryContext = PartnerRunningFlowContext.Companion.fromSelf(input);
|
||||||
|
primaryContext.setTarget(target);
|
||||||
PartnerRunningFlowContext executedContext = AgentRuntime.INSTANCE.submit(primaryContext);
|
PartnerRunningFlowContext executedContext = AgentRuntime.INSTANCE.submit(primaryContext);
|
||||||
return executedContext.getCoreResponse().getString("text");
|
return executedContext.getCoreResponse().getString("text");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ public class ActionPlanner extends AbstractAgentModule.Running<PartnerRunningFlo
|
|||||||
Schedulable.ScheduleType.ONCE,
|
Schedulable.ScheduleType.ONCE,
|
||||||
asScheduleContent(pendingAction.getRemindAt()),
|
asScheduleContent(pendingAction.getRemindAt()),
|
||||||
new StateAction.Trigger.Call(() -> {
|
new StateAction.Trigger.Call(() -> {
|
||||||
handlePendingReminder(pendingAction.getPendingId());
|
handlePendingReminder(pendingAction.getPendingId(), pendingAction.getUserId());
|
||||||
return Unit.INSTANCE;
|
return Unit.INSTANCE;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -221,14 +221,14 @@ public class ActionPlanner extends AbstractAgentModule.Running<PartnerRunningFlo
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePendingReminder(String pendingId) {
|
private void handlePendingReminder(String pendingId, String userId) {
|
||||||
boolean marked = actionCapability.markPendingReminded(pendingId);
|
boolean marked = actionCapability.markPendingReminded(pendingId);
|
||||||
if (!marked) {
|
if (!marked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// TODO target 指定行为待补充; 主动回复链路待补充
|
// TODO target 指定行为待补充; 主动回复链路待补充
|
||||||
cognationCapability.initiateTurn("系统提醒:存在待确认行动即将过期,请确认是否继续执行。pendingId=" + pendingId);
|
cognationCapability.initiateTurn("系统提醒:存在待确认行动即将过期,请确认是否继续执行。pendingId=" + pendingId, userId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("触发待确认行动提醒失败, pendingId: {}", pendingId, e);
|
log.warn("触发待确认行动提醒失败, pendingId: {}", pendingId, e);
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ public class ActionPlanner extends AbstractAgentModule.Running<PartnerRunningFlo
|
|||||||
result == null ? "" : result //将会在 ActionExecutor
|
result == null ? "" : result //将会在 ActionExecutor
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
cognationCapability.initiateTurn(structuredSignal);
|
cognationCapability.initiateTurn(structuredSignal, action.getSource());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("触发 immediate 行动完成自对话失败, actionUuid: {}", action.getUuid(), e);
|
log.warn("触发 immediate 行动完成自对话失败, actionUuid: {}", action.getUuid(), e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user