diff --git a/src/memos/templates/mem_reader_prompts.py b/src/memos/templates/mem_reader_prompts.py index 6fb7a13c..e8808653 100644 --- a/src/memos/templates/mem_reader_prompts.py +++ b/src/memos/templates/mem_reader_prompts.py @@ -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: @@ -25,20 +25,23 @@ { "memory list": [ { - "key": , + "key": , "memory_type": , - "value": , - "tags": + "value": , + "tags": }, ... ], - "summary": + "summary": } 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: @@ -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} @@ -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. diff --git a/src/memos/templates/tree_reorganize_prompts.py b/src/memos/templates/tree_reorganize_prompts.py index 8b62a254..04435eeb 100644 --- a/src/memos/templates/tree_reorganize_prompts.py +++ b/src/memos/templates/tree_reorganize_prompts.py @@ -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": "", @@ -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": [ @@ -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 = """ @@ -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",