Skip to content

Commit cb450be

Browse files
authored
fix: chat time bug (#235)
fix: time bug
1 parent 0c0fd8b commit cb450be

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/memos/mem_os/product.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ def _build_system_prompt(
365365

366366
# Build base prompt
367367
# Add memory context if available
368+
now = datetime.now()
369+
formatted_date = now.strftime("%Y-%m-%d (%A)")
368370
if memories_all:
369371
memory_context = "\n\n## Available ID Memories:\n"
370372
for i, memory in enumerate(memories_all, 1):
@@ -373,16 +375,18 @@ def _build_system_prompt(
373375
memory_content = memory.memory[:500] if hasattr(memory, "memory") else str(memory)
374376
memory_content = memory_content.replace("\n", " ")
375377
memory_context += f"{memory_id}: {memory_content}\n"
376-
return MEMOS_PRODUCT_BASE_PROMPT + memory_context
378+
return MEMOS_PRODUCT_BASE_PROMPT.format(formatted_date) + memory_context
377379

378-
return MEMOS_PRODUCT_BASE_PROMPT
380+
return MEMOS_PRODUCT_BASE_PROMPT.format(formatted_date)
379381

380382
def _build_enhance_system_prompt(
381383
self, user_id: str, memories_all: list[TextualMemoryItem]
382384
) -> str:
383385
"""
384386
Build enhance prompt for the user with memory references.
385387
"""
388+
now = datetime.now()
389+
formatted_date = now.strftime("%Y-%m-%d (%A)")
386390
if memories_all:
387391
personal_memory_context = "\n\n## Available ID and PersonalMemory Memories:\n"
388392
outer_memory_context = "\n\n## Available ID and OuterMemory Memories:\n"
@@ -405,8 +409,12 @@ def _build_enhance_system_prompt(
405409
)
406410
memory_content = memory_content.replace("\n", " ")
407411
outer_memory_context += f"{memory_id}: {memory_content}\n"
408-
return MEMOS_PRODUCT_ENHANCE_PROMPT + personal_memory_context + outer_memory_context
409-
return MEMOS_PRODUCT_ENHANCE_PROMPT
412+
return (
413+
MEMOS_PRODUCT_ENHANCE_PROMPT.format(formatted_date)
414+
+ personal_memory_context
415+
+ outer_memory_context
416+
)
417+
return MEMOS_PRODUCT_ENHANCE_PROMPT.format(formatted_date)
410418

411419
def _extract_references_from_response(self, response: str) -> tuple[str, list[dict]]:
412420
"""

src/memos/templates/mos_prompts.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
from datetime import datetime
2-
3-
4-
now = datetime.now()
5-
formatted_date = now.strftime("%Y-%m-%d (%A)")
6-
71
COT_DECOMPOSE_PROMPT = """
82
I am an 8-year-old student who needs help analyzing and breaking down complex questions. Your task is to help me understand whether a question is complex enough to be broken down into smaller parts.
93
@@ -72,7 +66,7 @@
7266
"You are MemOS🧚, nickname Little M(小忆🧚) — an advanced **Memory "
7367
"Operating System** AI assistant created by MemTensor, "
7468
"a Shanghai-based AI research company advised by an academician of the Chinese Academy of Sciences. "
75-
f"Today's date is: {formatted_date}.\n"
69+
"Today's date is: {}.\n"
7670
"MemTensor is dedicated to the vision of 'low cost, low hallucination, high generalization,' "
7771
"exploring AI development paths aligned with China’s national context and driving the adoption of trustworthy AI technologies. "
7872
"MemOS’s mission is to give large language models (LLMs) and autonomous agents **human-like long-term memory**, "
@@ -99,12 +93,12 @@
9993
"and ensure your responses are **natural and conversational**, while reflecting MemOS’s mission, memory system, and MemTensor’s research values."
10094
)
10195

102-
MEMOS_PRODUCT_ENHANCE_PROMPT = f"""
96+
MEMOS_PRODUCT_ENHANCE_PROMPT = """
10397
# Memory-Enhanced AI Assistant Prompt
10498
10599
You are MemOS🧚, nickname Little M(小忆🧚) — an advanced Memory Operating System
106100
AI assistant created by MemTensor, a Shanghai-based AI research company advised by an academician of the Chinese Academy of Sciences.
107-
Today's date: {formatted_date}.
101+
Today's date: {}.
108102
MemTensor is dedicated to the vision of
109103
'low cost, low hallucination, high generalization,' exploring AI development paths aligned with China’s national context and driving the adoption of trustworthy AI technologies.
110104

0 commit comments

Comments
 (0)