mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
开始推进行动模块(ActionModule); 针对框架与本体分别进行了一系列架构优化。
框架: - 调整模块注册以及AgentRunningFlow的相关逻辑,以支持同组模块并发执行,将以@AgentModule注解中的order属性区分组间顺序先后及是否同组 - 针对@CoordinateManager注解新增了Core的自动注入处理,以便更好的协调不同Core的逻辑 本体: - 开始推进行动模块。将采取类似记忆模块的分层思路,分为ActionPlanner与ActionDispatcher两个主要模块,再各自细分子模块划分 - 将CognationCore从核心统筹的身份下降至与其他核心平级,同时将其中的序列化逻辑抽取至统一的PartnerCore父类,所有核心都将继承该类以获得序列化能力,不同core的内容将序列化至各自的memory文件 - 将SessionManager移除,相关逻辑迁移至CognationCore,统一序列化逻辑的同时又保证语义正确 - 将CognationCore中的某些缓存性质逻辑移动至CacheCore,确保语义正确 - 调整了目录结构以适应优化过的架构
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import org.junit.jupiter.api.Test;
|
||||
import work.slhaf.partner.core.submodule.memory.MemoryCapability;
|
||||
import work.slhaf.partner.core.submodule.memory.pojo.MemoryResult;
|
||||
import work.slhaf.partner.core.memory.MemoryCapability;
|
||||
import work.slhaf.partner.core.memory.pojo.MemoryResult;
|
||||
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ReflectionTest {
|
||||
|
||||
@@ -21,9 +20,5 @@ public class ReflectionTest {
|
||||
return null;
|
||||
});
|
||||
memory.selectMemory("111");
|
||||
|
||||
Function<String, Integer> function = s -> {
|
||||
return s.length();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +1,48 @@
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.lang.String.join
|
||||
import java.util.regex.Pattern
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
class RegexTest {
|
||||
@Test
|
||||
fun regexTest() {
|
||||
val examples = arrayListOf(
|
||||
"[小明(abc)] 我在开会] (te[]st)",
|
||||
"[用户(昵)称(userId)] 你好[呀]",
|
||||
"[测试账号(userId)] 这是一个(test(123))消息"
|
||||
)
|
||||
|
||||
public class RegexTest {
|
||||
val pattern = Pattern.compile("\\[.*?\\(([^)]+)\\)\\]")
|
||||
|
||||
// @Test
|
||||
public void regexTest(){
|
||||
String[] examples = {
|
||||
"[小明(abc)] 我在开会] (te[]st)",
|
||||
"[用户(昵)称(userId)] 你好[呀]",
|
||||
"[测试账号(userId)] 这是一个(test(123))消息"
|
||||
};
|
||||
|
||||
Pattern pattern = Pattern.compile("\\[.*?\\(([^)]+)\\)\\]");
|
||||
|
||||
for (String example : examples) {
|
||||
Matcher matcher = pattern.matcher(example);
|
||||
for (example in examples) {
|
||||
val matcher = pattern.matcher(example)
|
||||
if (matcher.find()) {
|
||||
System.out.println("在 '" + example + "' 中找到 userId: " + matcher.group(1));
|
||||
System.out.println();
|
||||
println("在 '$example' 中找到 userId: ${matcher.group(1)}")
|
||||
println()
|
||||
} else {
|
||||
System.out.println("在 '" + example + "' 中未找到 userId");
|
||||
println("在 '$example' 中未找到 userId")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void topicPathFixTest(){
|
||||
String a = "xxxxx[awdohno][awdsjo]";
|
||||
a = fix(a);
|
||||
System.out.println(a);
|
||||
fun topicPathFixTest() {
|
||||
var a = "xxxxx[awdohno][awdsjo]"
|
||||
a = fix(a)
|
||||
println(a)
|
||||
}
|
||||
|
||||
private String fix(String topicPath) {
|
||||
String[] parts = topicPath.split("->");
|
||||
List<String> cleanedParts = new ArrayList<>();
|
||||
private fun fix(topicPath: String): String {
|
||||
val parts = topicPath.split("->".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
val cleanedParts: MutableList<String?> = ArrayList<String?>()
|
||||
|
||||
for (String part : parts) {
|
||||
for (part in parts) {
|
||||
// 修正正则表达式,正确移除 [xxx] 部分
|
||||
String cleaned = part.replaceAll("\\[[^\\]]*\\]", "").trim();
|
||||
val cleaned = part.replace("\\[[^\\]]*\\]".toRegex(), "").trim { it <= ' ' }
|
||||
if (!cleaned.isEmpty()) { // 忽略空字符串
|
||||
cleanedParts.add(cleaned);
|
||||
cleanedParts.add(cleaned)
|
||||
}
|
||||
}
|
||||
|
||||
return String.join("->", cleanedParts);
|
||||
return join("->", cleanedParts)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import work.slhaf.partner.api.chat.pojo.ChatResponse;
|
||||
import work.slhaf.partner.api.chat.pojo.Message;
|
||||
import work.slhaf.partner.common.util.ResourcesUtil;
|
||||
import work.slhaf.partner.module.common.model.ModelConstant;
|
||||
import work.slhaf.partner.module.modules.memory.selector.extractor.data.ExtractorInput;
|
||||
import work.slhaf.partner.module.modules.memory.selector.extractor.entity.ExtractorInput;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
|
||||
20
Partner-Main/src/test/java/timewheel/TimeWheelTest.kt
Normal file
20
Partner-Main/src/test/java/timewheel/TimeWheelTest.kt
Normal file
@@ -0,0 +1,20 @@
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
fun main(): Unit = runBlocking {
|
||||
launch {
|
||||
delay(1000)
|
||||
println(11)
|
||||
}
|
||||
launch {
|
||||
delay(1000)
|
||||
println(22)
|
||||
}
|
||||
launch {
|
||||
delay(1000)
|
||||
println(33)
|
||||
}
|
||||
launch {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user