Skip to content

Commit f8859f1

Browse files
authored
Hotfix: memos playground prompt reverse (#408)
hotfix: memos playground
1 parent d79647e commit f8859f1

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

src/memos/mem_os/product.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,22 +1044,15 @@ def chat(
10441044
m.metadata.embedding = []
10451045
new_memories_list.append(m)
10461046
memories_list = new_memories_list
1047-
# Build base system prompt without memory
1048-
system_prompt = self._build_base_system_prompt(base_prompt, mode="base")
1049-
1050-
# Build memory context to be included in user message
1051-
memory_context = self._build_memory_context(memories_list, mode="base")
1052-
1053-
# Combine memory context with user query
1054-
user_content = memory_context + query if memory_context else query
10551047

1048+
system_prompt = super()._build_system_prompt(memories_list, base_prompt)
10561049
history_info = []
10571050
if history:
10581051
history_info = history[-20:]
10591052
current_messages = [
10601053
{"role": "system", "content": system_prompt},
10611054
*history_info,
1062-
{"role": "user", "content": user_content},
1055+
{"role": "user", "content": query},
10631056
]
10641057
response = self.chat_llm.generate(current_messages)
10651058
time_end = time.time()
@@ -1129,16 +1122,8 @@ def chat_with_references(
11291122

11301123
reference = prepare_reference_data(memories_list)
11311124
yield f"data: {json.dumps({'type': 'reference', 'data': reference})}\n\n"
1132-
1133-
# Build base system prompt without memory
1134-
system_prompt = self._build_base_system_prompt(mode="enhance")
1135-
1136-
# Build memory context to be included in user message
1137-
memory_context = self._build_memory_context(memories_list, mode="enhance")
1138-
1139-
# Combine memory context with user query
1140-
user_content = memory_context + query if memory_context else query
1141-
1125+
# Build custom system prompt with relevant memories)
1126+
system_prompt = self._build_enhance_system_prompt(user_id, memories_list)
11421127
# Get chat history
11431128
if user_id not in self.chat_history_manager:
11441129
self._register_chat_history(user_id, session_id)
@@ -1149,7 +1134,7 @@ def chat_with_references(
11491134
current_messages = [
11501135
{"role": "system", "content": system_prompt},
11511136
*chat_history.chat_history,
1152-
{"role": "user", "content": user_content},
1137+
{"role": "user", "content": query},
11531138
]
11541139
logger.info(
11551140
f"user_id: {user_id}, cube_id: {cube_id}, current_system_prompt: {system_prompt}"

0 commit comments

Comments
 (0)