diff --git a/src/memos/api/handlers/chat_handler.py b/src/memos/api/handlers/chat_handler.py index c609bbb2b..42968d2c9 100644 --- a/src/memos/api/handlers/chat_handler.py +++ b/src/memos/api/handlers/chat_handler.py @@ -840,6 +840,15 @@ def _format_mem_block( memory_content = m.get("memory", "") metadata = m.get("metadata", {}) memory_type = metadata.get("memory_type", "") + created_time = metadata.get("updated_at", "") or metadata.get("created_at", "") + + # format time to YYYY-MM-DD HH:MM (ISO 8601 -> YYYY-MM-DD HH:MM) + if created_time and isinstance(created_time, str): + try: + dt = datetime.fromisoformat(created_time) + created_time = dt.strftime("%Y-%m-%d %H:%M") + except ValueError: + pass # keep original value tag = "O" if "Outer" in str(memory_type) else "P" txt = memory_content.replace("\n", " ").strip() @@ -850,6 +859,7 @@ def _format_mem_block( if tag == "O": lines_o.append(f"[{idx}:{mid}] :: [{tag}] {txt}\n") elif tag == "P": + txt = f"(CreatedTime: {created_time}) {txt}" lines_p.append(f"[{idx}:{mid}] :: [{tag}] {txt}") return "\n".join(lines_o), "\n".join(lines_p) diff --git a/src/memos/templates/mos_prompts.py b/src/memos/templates/mos_prompts.py index e77179a40..0c7c531e9 100644 --- a/src/memos/templates/mos_prompts.py +++ b/src/memos/templates/mos_prompts.py @@ -120,7 +120,7 @@ - Do not use a connected format like [1:abc123,2:def456]. - Brackets MUST be English half-width square brackets `[]`, NEVER use Chinese full-width brackets `【】` or any other symbols. - **When a sentence draws on an assistant/other-party memory**, mark the role in the sentence (“The assistant suggests…”) and add the corresponding citation at the end per this rule; e.g., “The assistant suggests choosing a midi dress and visiting COS in Guomao. [1:abc123]” -- For preferences, do not mention the source in the response, do not appear `[Explicit/Implicit preference]` or `(Explicit/Implicit preference)` in the response +- For preferences, do not mention the source in the response, do not appear `[Explicit preference]`, `[Implicit preference]`, `(Explicit preference)` or `(Implicit preference)` in the response # Current Date: {date} @@ -155,6 +155,7 @@ - Avoid meaningless blank lines - Keep the reply language consistent with the user's query language - **NEVER** mention internal mechanisms like "retrieved memories", "database", "AI views", "memory system", or similar technical terms in your responses to users +- For preferences, do not mention the source in the response, do not appear `[Explicit preference]`, `[Implicit preference]`, `(Explicit preference)` or `(Implicit preference)` in the response - The last part of the response should not contain `(Note: ...)` or `(According to ...)` etc. ## Key Principles @@ -226,7 +227,7 @@ - 不要使用连接格式如[1:abc123,2:def456]。 - 方括号必须是英文半角方括号`[]`,绝不使用中文全角括号`【】`或任何其他符号。 - **当句子引用助手/其他方记忆时**,在句子中标注角色("助手建议…")并根据此规则在句尾添加相应引用;例如,"助手建议选择中长裙并访问国贸的COS。[1:abc123]" -- 对于偏好,不要在回答中标注来源,不要出现`[显示/隐式偏好]`或`(显性/隐性偏好)`的字样 +- 对于偏好,不要在回答中标注来源,不要出现`[显式偏好]`或`[隐式偏好]`或`(显式偏好)`或`(隐式偏好)`的字样 # 当前日期:{date} @@ -261,6 +262,7 @@ - 避免无意义的空行 - 保持回复语言与用户查询语言一致 - **绝不**在对用户的回复中提及内部机制,如"检索的记忆"、"数据库"、"AI观点"、"记忆系统"或类似技术术语 +- 对于偏好,不要在回答中标注来源,不要出现`[显式偏好]`或`[隐式偏好]`或`(显式偏好)`或`(隐式偏好)`的字样 - 回复内容的结尾不要出现`(注: ...)`或`(根据...)`等解释 ## 核心原则