Merge 2d12a33a7cfa50e869a9bda9d8f7bf044129cc1e into 598f1826d8b2bc969aace2c6459824737667218c
This commit is contained in:
commit
4736ad1a25
@ -237,6 +237,8 @@ describe("memory plugin e2e", () => {
|
||||
expect(shouldCapture("My email is test@example.com")).toBe(true);
|
||||
expect(shouldCapture("Call me at +1234567890123")).toBe(true);
|
||||
expect(shouldCapture("I always want verbose output")).toBe(true);
|
||||
expect(shouldCapture("请记住我喜欢深色模式")).toBe(true);
|
||||
expect(shouldCapture("我决定以后都用 TypeScript")).toBe(true);
|
||||
expect(shouldCapture("x")).toBe(false);
|
||||
expect(shouldCapture("<relevant-memories>injected</relevant-memories>")).toBe(false);
|
||||
expect(shouldCapture("<system>status</system>")).toBe(false);
|
||||
@ -281,9 +283,23 @@ describe("memory plugin e2e", () => {
|
||||
const { detectCategory } = await import("./index.js");
|
||||
|
||||
expect(detectCategory("I prefer dark mode")).toBe("preference");
|
||||
expect(detectCategory("I need dark mode")).toBe("preference");
|
||||
expect(detectCategory("I always use dark mode")).toBe("preference");
|
||||
expect(detectCategory("I never use emojis")).toBe("preference");
|
||||
expect(detectCategory("This is important for me")).toBe("preference");
|
||||
expect(detectCategory("Preferuji tmavý režim")).toBe("preference");
|
||||
expect(detectCategory("Nechci používat světlý režim")).toBe("preference");
|
||||
expect(detectCategory("我喜欢深色模式")).toBe("preference");
|
||||
expect(detectCategory("We decided to use React")).toBe("decision");
|
||||
expect(detectCategory("我们决定以后都用 React")).toBe("decision");
|
||||
expect(detectCategory("我决定以后都用 TypeScript")).toBe("decision");
|
||||
expect(detectCategory("My email is test@example.com")).toBe("entity");
|
||||
expect(detectCategory("我是张三")).toBe("entity");
|
||||
expect(detectCategory("我叫小明")).toBe("entity");
|
||||
expect(detectCategory("The server is running on port 3000")).toBe("fact");
|
||||
expect(detectCategory("服务器状态是正常")).toBe("fact");
|
||||
expect(detectCategory("我们有 3 台服务器")).toBe("fact");
|
||||
expect(detectCategory("我有问题吗?")).toBe("other");
|
||||
expect(detectCategory("Random note")).toBe("other");
|
||||
});
|
||||
});
|
||||
|
||||
@ -193,6 +193,11 @@ const MEMORY_TRIGGERS = [
|
||||
/zapamatuj si|pamatuj|remember/i,
|
||||
/preferuji|radši|nechci|prefer/i,
|
||||
/rozhodli jsme|budeme používat/i,
|
||||
/记住|记得|请记|别忘|不要忘/,
|
||||
/我喜欢|我偏好|我讨厌|我不喜欢|我爱|我想要|我需要/,
|
||||
/我决定|我们决定|就这么定|以后都|以后用/,
|
||||
/我的.+是|是我的|我叫|我是/,
|
||||
/重要|总是|从不|一定要|必须|千万/,
|
||||
/\+\d{10,}/,
|
||||
/[\w.-]+@[\w.-]+\.\w+/,
|
||||
/můj\s+\w+\s+je|je\s+můj/i,
|
||||
@ -270,16 +275,34 @@ export function shouldCapture(text: string, options?: { maxChars?: number }): bo
|
||||
|
||||
export function detectCategory(text: string): MemoryCategory {
|
||||
const lower = text.toLowerCase();
|
||||
if (/prefer|radši|like|love|hate|want/i.test(lower)) {
|
||||
if (
|
||||
/prefer|preferuji|radši|nechci|like|love|hate|want|need|always|never|important/i.test(lower)
|
||||
) {
|
||||
return "preference";
|
||||
}
|
||||
if (/我喜欢|我偏好|我讨厌|我不喜欢|我爱|我想要|我需要/.test(text)) {
|
||||
return "preference";
|
||||
}
|
||||
if (/我喜欢|我偏好|我讨厌|我不喜欢|我爱|我想要|我需要/.test(text)) {
|
||||
return "preference";
|
||||
}
|
||||
if (/rozhodli|decided|will use|budeme/i.test(lower)) {
|
||||
return "decision";
|
||||
}
|
||||
if (/我决定|我们决定|就这么定|以后都|以后用/.test(text)) {
|
||||
return "decision";
|
||||
}
|
||||
if (/\+\d{10,}|@[\w.-]+\.\w+|is called|jmenuje se/i.test(lower)) {
|
||||
return "entity";
|
||||
}
|
||||
if (/is|are|has|have|je|má|jsou/i.test(lower)) {
|
||||
if (/我叫|我是|我的.+是|是我的/.test(text)) {
|
||||
return "entity";
|
||||
}
|
||||
if (/is|are|has|have|je|má|jsou|事实|信息|状态|版本|配置|地址|端口/.test(lower)) {
|
||||
return "fact";
|
||||
}
|
||||
// Avoid broad CJK copulas ("是/有"), which often appear in questions.
|
||||
if (!/[??]/.test(text) && /我有|我们有|具备|包含|属于/.test(text)) {
|
||||
return "fact";
|
||||
}
|
||||
return "other";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user