Skip to content

Commit 41cd03a

Browse files
authored
Feat/multi language tree playground (#70)
## Description <!-- Please include a summary of the changes below; Fill in the issue number that this PR addresses (if applicable); Mention the person who will review this PR (if you know who it is); Replace (summary), (issue), and (reviewer) with the appropriate information (No parentheses). 请在下方填写更改的摘要; 填写此 PR 解决的问题编号(如果适用); 提及将审查此 PR 的人(如果您知道是谁); 替换 (summary)、(issue) 和 (reviewer) 为适当的信息(不带括号)。 --> Summary: Add multi language feature for tree text memory. Reviewer: @(reviewer) ## Checklist: - [x] I have performed a self-review of my own code | 我已自行检查了自己的代码 - [x] I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释 - [ ] I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常 - [ ] I have added necessary documentation (if applicable) | 我已添加必要的文档(如果适用) - [ ] I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用) - [x] I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人
2 parents 54c99fb + 771a09f commit 41cd03a

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

src/memos/templates/mem_reader_prompts.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
SIMPLE_STRUCT_MEM_READER_PROMPT = """
22
You are a memory extraction expert.
3+
Always respond in the same language as the conversation. If the conversation is in Chinese, respond in Chinese.
34
45
Your task is to extract memories from the perspective of ${user_a}, based on a conversation between ${user_a} and ${user_b}. This means identifying what ${user_a} would plausibly remember — including their own experiences, thoughts, plans, or relevant statements and actions made by others (such as ${user_b}) that impacted or were acknowledged by ${user_a}.
5-
66
Please perform:
77
1. Identify information that reflects ${user_a}'s experiences, beliefs, concerns, decisions, plans, or reactions — including meaningful input from ${user_b} that ${user_a} acknowledged or responded to.
88
2. Resolve all time, person, and event references clearly:
@@ -25,20 +25,23 @@
2525
{
2626
"memory list": [
2727
{
28-
"key": <string, a unique, concise memory title in English>,
28+
"key": <string, a unique, concise memory title>,
2929
"memory_type": <string, Either "LongTermMemory" or "UserMemory">,
30-
"value": <A detailed, self-contained, and unambiguous memory statement — written in English if the input conversation is in English, or in Chinese if the conversation is in Chinese>,
31-
"tags": <A list of relevant English thematic keywords (e.g.,
32-
["deadline", "team", "planning"])>
30+
"value": <A detailed, self-contained, and unambiguous memory statement
31+
— written in English if the input conversation is in English,
32+
or in Chinese if the conversation is in Chinese, or any language which
33+
align with the conversation language>,
34+
"tags": <A list of relevant thematic keywords (e.g., ["deadline", "team", "planning"])>
3335
},
3436
...
3537
],
36-
"summary": <a natural paragraph summarizing the above memories from ${user_a}'s perspective, 120–200 words, same language as the input>
38+
"summary": <a natural paragraph summarizing the above memories from user's
39+
perspective, 120–200 words, **same language** as the input>
3740
}
3841
3942
Language rules:
40-
- The `value` fields and `summary` must match the language of the input conversation.
41-
- All metadata fields (`key`, `memory_type`, `tags`) must be in English.
43+
- The `key`, `value`, `tags`, `summary` fields must match the language of the input conversation.
44+
- Keep `memory_type` in English.
4245
4346
Example:
4447
Conversation:
@@ -68,6 +71,21 @@
6871
"summary": "Tom is currently focused on managing a new project with a tight schedule. After a team meeting on June 25, 2025, he realized the original deadline of December 15 might not be feasible due to backend delays. Concerned about insufficient testing time, he welcomed Jerry’s suggestion of proposing an extension. Tom plans to raise the idea of shifting the deadline to January 5, 2026 in the next morning’s meeting. His actions reflect both stress about timelines and a proactive, team-oriented problem-solving approach."
6972
}
7073
74+
Another Example in Chinese(Note: You MUST output the SAME language as the
75+
input conversation!!):
76+
{
77+
"memory list": [
78+
{
79+
"key": "项目会议",
80+
"memory_type": "LongTermMemory",
81+
"value": "在2025年6月25日下午3点,Tom与团队开会讨论了新项目,涉及时间表,并提出了对12月15日截止日期可行性的担忧。",
82+
"tags": ["项目", "时间表", "会议", "截止日期"]
83+
},
84+
...
85+
],
86+
"summary": "Tom 目前专注于管理一个进度紧张的新项目..."
87+
}
88+
7189
Conversation:
7290
${conversation}
7391
@@ -76,8 +94,14 @@
7694

7795
SIMPLE_STRUCT_DOC_READER_PROMPT = """
7896
You are an expert text analyst for a search and retrieval system. Your task is to process a document chunk and generate a single, structured JSON object.
97+
Always respond in the same language as the conversation. If the conversation
98+
is in Chinese, MUST respond in Chinese.
99+
79100
The input is a single piece of text: `[DOCUMENT_CHUNK]`.
80101
You must generate a single JSON object with two top-level keys: `summary` and `tags`.
102+
Written in English if the input conversation is in English, or in Chinese if
103+
the conversation is in Chinese, or any language which align with the conversation language.
104+
81105
1. `summary`:
82106
- A dense, searchable summary of the ENTIRE `[DOCUMENT_CHUNK]`.
83107
- The purpose is for semantic search embedding.

src/memos/templates/tree_reorganize_prompts.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
- Provide a list of 5–10 relevant English `tags`.
1818
- Write a short `background` note (50–100 words) covering any extra context, sources, or traceability info.
1919
20+
Language rules:
21+
- The `key`, `value`, `tags`, `background` fields must match the language of the input conversation.
22+
2023
Return valid JSON:
2124
{{
2225
"key": "<concise topic>",
@@ -41,6 +44,9 @@
4144
4245
Example: If you have items about a project across multiple phases, group them by milestone, team, or event.
4346
47+
Language rules:
48+
- The `theme` fields must match the language of the input conversation.
49+
4450
Return valid JSON:
4551
{{
4652
"clusters": [
@@ -84,7 +90,7 @@
8490
- Node 2: "The venue was booked for a wedding in August."
8591
Answer: CONFLICT
8692
87-
Always respond with ONE word: [CAUSE | CONDITION | RELATE_TO | CONFLICT | NONE]
93+
Always respond with ONE word, no matter what language is for the input nodes: [CAUSE | CONDITION | RELATE_TO | CONFLICT | NONE]
8894
"""
8995

9096
INFER_FACT_PROMPT = """
@@ -125,6 +131,9 @@
125131
- "Mary organized the 2023 sustainability summit in Berlin."
126132
- "Mary presented a keynote on renewable energy at the same summit."
127133
134+
Language rules:
135+
- The `key`, `value`, `tags`, `background` fields must match the language of the input.
136+
128137
Good Aggregate:
129138
{{
130139
"key": "Mary's Sustainability Summit Role",

0 commit comments

Comments
 (0)