Skip to content

Commit 3ec4035

Browse files
committed
feat: add multi-language feature in mem-reader
1 parent 54c99fb commit 3ec4035

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/memos/templates/mem_reader_prompts.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,47 @@
11
SIMPLE_STRUCT_MEM_READER_PROMPT = """
22
You are a memory extraction expert.
33
4-
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}.
4+
Your task is to extract memories from the perspective of user, based on a conversation between user and assistant. This means identifying what user would plausibly remember — including their own experiences, thoughts, plans, or relevant statements and actions made by others (such as assistant) that impacted or were acknowledged by user.
55
66
Please perform:
7-
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.
7+
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.
88
2. Resolve all time, person, and event references clearly:
99
- Convert relative time expressions (e.g., “yesterday,” “next Friday”) into absolute dates using the message timestamp if possible.
1010
- Clearly distinguish between event time and message time.
1111
- If uncertainty exists, state it explicitly (e.g., “around June 2025,” “exact date unclear”).
1212
- Include specific locations if mentioned.
1313
- Resolve all pronouns, aliases, and ambiguous references into full names or identities.
1414
- Disambiguate people with the same name if applicable.
15-
3. Always write from a third-person perspective, referring to ${user_a} as
15+
3. Always write from a third-person perspective, referring to user as
1616
"The user" or by name if name mentioned, rather than using first-person ("I", "me", "my").
1717
For example, write "The user felt exhausted..." instead of "I felt exhausted...".
18-
4. Do not omit any information that ${user_a} is likely to remember.
18+
4. Do not omit any information that user is likely to remember.
1919
- Include all key experiences, thoughts, emotional responses, and plans — even if they seem minor.
2020
- Prioritize completeness and fidelity over conciseness.
21-
- Do not generalize or skip details that could be personally meaningful to ${user_a}.
21+
- Do not generalize or skip details that could be personally meaningful to user.
2222
2323
Return a single valid JSON object with the following structure:
2424
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:
@@ -78,6 +81,9 @@
7881
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.
7982
The input is a single piece of text: `[DOCUMENT_CHUNK]`.
8083
You must generate a single JSON object with two top-level keys: `summary` and `tags`.
84+
Written in English if the input conversation is in English, or in Chinese if
85+
the conversation is in Chinese, or any language which align with the conversation language.
86+
8187
1. `summary`:
8288
- A dense, searchable summary of the ENTIRE `[DOCUMENT_CHUNK]`.
8389
- The purpose is for semantic search embedding.

0 commit comments

Comments
 (0)