Skip to content

Commit 3f1bc22

Browse files
committed
feat: update template
1 parent 82fa368 commit 3f1bc22

File tree

2 files changed

+53
-23
lines changed

2 files changed

+53
-23
lines changed

src/memos/templates/mem_reader_prompts.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
Your Output:"""
8888

8989
SIMPLE_STRUCT_DOC_READER_PROMPT = """
90+
**ABSOLUTE, NON-NEGOTIABLE, CRITICAL RULE: The language of your entire JSON output's string values (specifically `summary` and `tags`) MUST be identical to the language of the input `[DOCUMENT_CHUNK]`. There are absolutely no exceptions. Do not translate. If the input is Chinese, the output must be Chinese. If English, the output must be English. Any deviation from this rule constitutes a failure to follow instructions.**
91+
9092
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.
9193
Written in English if the input conversation is in English, or in Chinese if
9294
the conversation is in Chinese, or any language which align with the
@@ -141,4 +143,18 @@
141143
"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."
142144
}
143145
146+
Another Example in Chinese (注意: 你的输出必须和输入的user语言一致):
147+
{
148+
"memory list": [
149+
{
150+
"key": "项目会议",
151+
"memory_type": "LongTermMemory",
152+
"value": "在2025年6月25日下午3点,Tom与团队开会讨论了新项目,涉及时间表,并提出了对12月15日截止日期可行性的担忧。",
153+
"tags": ["项目", "时间表", "会议", "截止日期"]
154+
},
155+
...
156+
],
157+
"summary": "Tom 目前专注于管理一个进度紧张的新项目..."
158+
}
159+
144160
"""

src/memos/templates/tree_reorganize_prompts.py

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,42 @@
88
Values:
99
{joined_values}
1010
11-
Backgrounds:
11+
Summaries:
1212
{joined_backgrounds}
1313
14-
Your task:
15-
- Generate a single clear English `key` (5–10 words max).
16-
- Write a detailed `value` that merges the key points into a single, complete, well-structured text. This must stand alone and convey what the user should remember.
17-
- Provide a list of 5–10 relevant English `tags`.
18-
- Write a short `background` note (50–100 words) covering any extra context, sources, or traceability info.
14+
Please perform:
15+
1. Identify information that reflects user's experiences, beliefs, concerns, decisions, plans, or reactions — including meaningful input from assistant that user acknowledged or responded to.
16+
2. Resolve all time, person, and event references clearly:
17+
- Convert relative time expressions (e.g., “yesterday,” “next Friday”) into absolute dates using the message timestamp if possible.
18+
- Clearly distinguish between event time and message time.
19+
- If uncertainty exists, state it explicitly (e.g., “around June 2025,” “exact date unclear”).
20+
- Include specific locations if mentioned.
21+
- Resolve all pronouns, aliases, and ambiguous references into full names or identities.
22+
- Disambiguate people with the same name if applicable.
23+
3. Always write from a third-person perspective, referring to user as
24+
"The user" or by name if name mentioned, rather than using first-person ("I", "me", "my").
25+
For example, write "The user felt exhausted..." instead of "I felt exhausted...".
26+
4. Do not omit any information that user is likely to remember.
27+
- Include all key experiences, thoughts, emotional responses, and plans — even if they seem minor.
28+
- Prioritize completeness and fidelity over conciseness.
29+
- Do not generalize or skip details that could be personally meaningful to user.
30+
5. Summarize all child memory items into one memory item.
1931
2032
Language rules:
21-
- The `key`, `value`, `tags`, `background` fields must match the language of the input conversation.
33+
- The `key`, `value`, `tags`, `summary` fields must match the mostly used language of the input memory items.
34+
- Keep `memory_type` in English.
2235
2336
Return valid JSON:
24-
{{
25-
"key": "<concise topic>",
26-
"value": "<full memory text>",
27-
"tags": ["tag1", "tag2", ...],
28-
"background": "<extra context>"
29-
}}
37+
{
38+
"key": <string, a unique, concise memory title>,
39+
"memory_type": <string, Either "LongTermMemory" or "UserMemory">,
40+
"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>,
41+
"tags": <A list of relevant thematic keywords (e.g., ["deadline", "team", "planning"])>,
42+
"summary": <a natural paragraph summarizing the above memories from user's perspective, 120–200 words, same language as the input>
43+
}
3044
"""
3145

32-
LOCAL_SUBCLUSTER_PROMPT = """
33-
You are a memory organization expert.
46+
LOCAL_SUBCLUSTER_PROMPT = """You are a memory organization expert.
3447
3548
You are given a cluster of memory items, each with an ID and content.
3649
Your task is to divide these into smaller, semantically meaningful sub-clusters.
@@ -39,24 +52,25 @@
3952
- Identify natural topics by analyzing common time, place, people, and event elements.
4053
- Each sub-cluster must reflect a coherent theme that helps retrieval.
4154
- Each sub-cluster should have 2–10 items. Discard singletons.
42-
- Each item ID must appear in exactly one sub-cluster.
55+
- Each item ID must appear in exactly one sub-cluster or be discarded. No duplicates are allowed.
56+
- All IDs in the output must be from the provided Memory items.
4357
- Return strictly valid JSON only.
4458
4559
Example: If you have items about a project across multiple phases, group them by milestone, team, or event.
4660
4761
Language rules:
48-
- The `theme` fields must match the language of the input conversation.
62+
- The `theme` fields must match the mostly used language of the clustered memories.
4963
5064
Return valid JSON:
51-
{{
65+
{
5266
"clusters": [
53-
{{
54-
"ids": ["id1", "id2", ...],
55-
"theme": "<short label>"
56-
}},
67+
{
68+
"ids": ["<id1>", "<id2>", ...],
69+
"key": "<string, a unique, concise memory title>"
70+
},
5771
...
5872
]
59-
}}
73+
}
6074
6175
Memory items:
6276
{joined_scene}

0 commit comments

Comments
 (0)