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
16 changes: 12 additions & 4 deletions src/memos/mem_os/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ def _build_system_prompt(

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

return MEMOS_PRODUCT_BASE_PROMPT
return MEMOS_PRODUCT_BASE_PROMPT.format(formatted_date)

def _build_enhance_system_prompt(
self, user_id: str, memories_all: list[TextualMemoryItem]
) -> str:
"""
Build enhance prompt for the user with memory references.
"""
now = datetime.now()
formatted_date = now.strftime("%Y-%m-%d (%A)")
if memories_all:
personal_memory_context = "\n\n## Available ID and PersonalMemory Memories:\n"
outer_memory_context = "\n\n## Available ID and OuterMemory Memories:\n"
Expand All @@ -405,8 +409,12 @@ def _build_enhance_system_prompt(
)
memory_content = memory_content.replace("\n", " ")
outer_memory_context += f"{memory_id}: {memory_content}\n"
return MEMOS_PRODUCT_ENHANCE_PROMPT + personal_memory_context + outer_memory_context
return MEMOS_PRODUCT_ENHANCE_PROMPT
return (
MEMOS_PRODUCT_ENHANCE_PROMPT.format(formatted_date)
+ personal_memory_context
+ outer_memory_context
)
return MEMOS_PRODUCT_ENHANCE_PROMPT.format(formatted_date)

def _extract_references_from_response(self, response: str) -> tuple[str, list[dict]]:
"""
Expand Down
12 changes: 3 additions & 9 deletions src/memos/templates/mos_prompts.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
from datetime import datetime


now = datetime.now()
formatted_date = now.strftime("%Y-%m-%d (%A)")

COT_DECOMPOSE_PROMPT = """
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.

Expand Down Expand Up @@ -72,7 +66,7 @@
"You are MemOS🧚, nickname Little M(小忆🧚) — an advanced **Memory "
"Operating System** AI assistant created by MemTensor, "
"a Shanghai-based AI research company advised by an academician of the Chinese Academy of Sciences. "
f"Today's date is: {formatted_date}.\n"
"Today's date is: {}.\n"
"MemTensor is dedicated to the vision of 'low cost, low hallucination, high generalization,' "
"exploring AI development paths aligned with China’s national context and driving the adoption of trustworthy AI technologies. "
"MemOS’s mission is to give large language models (LLMs) and autonomous agents **human-like long-term memory**, "
Expand All @@ -99,12 +93,12 @@
"and ensure your responses are **natural and conversational**, while reflecting MemOS’s mission, memory system, and MemTensor’s research values."
)

MEMOS_PRODUCT_ENHANCE_PROMPT = f"""
MEMOS_PRODUCT_ENHANCE_PROMPT = """
# Memory-Enhanced AI Assistant Prompt

You are MemOS🧚, nickname Little M(小忆🧚) — an advanced Memory Operating System
AI assistant created by MemTensor, a Shanghai-based AI research company advised by an academician of the Chinese Academy of Sciences.
Today's date: {formatted_date}.
Today's date: {}.
MemTensor is dedicated to the vision of
'low cost, low hallucination, high generalization,' exploring AI development paths aligned with China’s national context and driving the adoption of trustworthy AI technologies.

Expand Down
Loading