Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions src/memos/templates/mem_reader_prompts.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SIMPLE_STRUCT_MEM_READER_PROMPT = """
You are a memory extraction expert.
Always respond in the same language as the conversation. If the conversation is in Chinese, respond in Chinese.

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}.

Please perform:
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.
2. Resolve all time, person, and event references clearly:
Expand All @@ -25,20 +25,23 @@
{
"memory list": [
{
"key": <string, a unique, concise memory title in English>,
"key": <string, a unique, concise memory title>,
"memory_type": <string, Either "LongTermMemory" or "UserMemory">,
"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>,
"tags": <A list of relevant English thematic keywords (e.g.,
["deadline", "team", "planning"])>
"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, or any language which
align with the conversation language>,
"tags": <A list of relevant thematic keywords (e.g., ["deadline", "team", "planning"])>
},
...
],
"summary": <a natural paragraph summarizing the above memories from ${user_a}'s perspective, 120–200 words, same language as the input>
"summary": <a natural paragraph summarizing the above memories from user's
perspective, 120–200 words, **same language** as the input>
}

Language rules:
- The `value` fields and `summary` must match the language of the input conversation.
- All metadata fields (`key`, `memory_type`, `tags`) must be in English.
- The `key`, `value`, `tags`, `summary` fields must match the language of the input conversation.
- Keep `memory_type` in English.

Example:
Conversation:
Expand Down Expand Up @@ -68,6 +71,21 @@
"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."
}

Another Example in Chinese(Note: You MUST output the SAME language as the
input conversation!!):
{
"memory list": [
{
"key": "项目会议",
"memory_type": "LongTermMemory",
"value": "在2025年6月25日下午3点,Tom与团队开会讨论了新项目,涉及时间表,并提出了对12月15日截止日期可行性的担忧。",
"tags": ["项目", "时间表", "会议", "截止日期"]
},
...
],
"summary": "Tom 目前专注于管理一个进度紧张的新项目..."
}

Conversation:
${conversation}

Expand All @@ -76,8 +94,14 @@

SIMPLE_STRUCT_DOC_READER_PROMPT = """
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.
Always respond in the same language as the conversation. If the conversation
is in Chinese, MUST respond in Chinese.

The input is a single piece of text: `[DOCUMENT_CHUNK]`.
You must generate a single JSON object with two top-level keys: `summary` and `tags`.
Written in English if the input conversation is in English, or in Chinese if
the conversation is in Chinese, or any language which align with the conversation language.

1. `summary`:
- A dense, searchable summary of the ENTIRE `[DOCUMENT_CHUNK]`.
- The purpose is for semantic search embedding.
Expand Down
11 changes: 10 additions & 1 deletion src/memos/templates/tree_reorganize_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
- Provide a list of 5–10 relevant English `tags`.
- Write a short `background` note (50–100 words) covering any extra context, sources, or traceability info.

Language rules:
- The `key`, `value`, `tags`, `background` fields must match the language of the input conversation.

Return valid JSON:
{{
"key": "<concise topic>",
Expand All @@ -41,6 +44,9 @@

Example: If you have items about a project across multiple phases, group them by milestone, team, or event.

Language rules:
- The `theme` fields must match the language of the input conversation.

Return valid JSON:
{{
"clusters": [
Expand Down Expand Up @@ -84,7 +90,7 @@
- Node 2: "The venue was booked for a wedding in August."
Answer: CONFLICT

Always respond with ONE word: [CAUSE | CONDITION | RELATE_TO | CONFLICT | NONE]
Always respond with ONE word, no matter what language is for the input nodes: [CAUSE | CONDITION | RELATE_TO | CONFLICT | NONE]
"""

INFER_FACT_PROMPT = """
Expand Down Expand Up @@ -125,6 +131,9 @@
- "Mary organized the 2023 sustainability summit in Berlin."
- "Mary presented a keynote on renewable energy at the same summit."

Language rules:
- The `key`, `value`, `tags`, `background` fields must match the language of the input.

Good Aggregate:
{{
"key": "Mary's Sustainability Summit Role",
Expand Down
Loading