mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
refactor(perceive): return Instant in showLastInteract
This commit is contained in:
@@ -2,9 +2,11 @@ package work.slhaf.partner.core.perceive;
|
|||||||
|
|
||||||
import work.slhaf.partner.api.agent.factory.capability.annotation.Capability;
|
import work.slhaf.partner.api.agent.factory.capability.annotation.Capability;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
@Capability(value = "perceive")
|
@Capability(value = "perceive")
|
||||||
public interface PerceiveCapability {
|
public interface PerceiveCapability {
|
||||||
String refreshInteract();
|
String refreshInteract();
|
||||||
|
|
||||||
long showLastInteract();
|
Instant showLastInteract();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ public class PerceiveCore extends PartnerCore<PerceiveCore> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CapabilityMethod
|
@CapabilityMethod
|
||||||
public long showLastInteract() {
|
public Instant showLastInteract() {
|
||||||
return lastInteractTime.toEpochMilli();
|
return lastInteractTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class MemoryUpdater extends AbstractAgentModule.Running<PartnerRunningFlo
|
|||||||
private void tryAutoUpdate() {
|
private void tryAutoUpdate() {
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
int chatCount = cognationCapability.snapshotChatMessages().size();
|
int chatCount = cognationCapability.snapshotChatMessages().size();
|
||||||
if (currentTime - perceiveCapability.showLastInteract() > UPDATE_TRIGGER_INTERVAL && chatCount > 1) {
|
if (currentTime - perceiveCapability.showLastInteract().toEpochMilli() > UPDATE_TRIGGER_INTERVAL && chatCount > 1) {
|
||||||
triggerMemoryUpdate(true);
|
triggerMemoryUpdate(true);
|
||||||
log.info("[MemoryUpdater] 记忆更新: 自动触发");
|
log.info("[MemoryUpdater] 记忆更新: 自动触发");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user