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
14 changes: 14 additions & 0 deletions src/memos/api/handlers/chat_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ def handle_chat_complete(self, chat_req: APIChatCompleteRequest) -> dict[str, An
if text_mem_results and text_mem_results[0].get("memories"):
memories_list = text_mem_results[0]["memories"]

# Drop internet memories forced
memories_list = [
mem
for mem in memories_list
if mem.get("metadata", {}).get("memory_type") != "OuterMemory"
]

# Filter memories by threshold
filtered_memories = self._filter_memories_by_threshold(
memories_list, chat_req.threshold or 0.5
Expand Down Expand Up @@ -277,6 +284,13 @@ def generate_chat_response() -> Generator[str, None, None]:
if text_mem_results and text_mem_results[0].get("memories"):
memories_list = text_mem_results[0]["memories"]

# Drop internet memories forced
memories_list = [
mem
for mem in memories_list
if mem.get("metadata", {}).get("memory_type") != "OuterMemory"
]

# Filter memories by threshold
filtered_memories = self._filter_memories_by_threshold(memories_list)

Expand Down
2 changes: 2 additions & 0 deletions src/memos/templates/prefer_complete_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
* **Contextual signals**: What do the user's choices, comparisons, exclusions, or scenario selections reveal about their deeper preferences?
- Do not treat explicitly stated preferences as implicit preferences; this prompt is only for inferring preferences that are not directly mentioned.
- Go beyond surface-level facts to understand the user's hidden possibilities and underlying logic.
- For Assistant's responses or suggestions, they can only be extracted as the user's implicit preferences if there is evidence in subsequent conversation that the user implicitly accepted them (e.g., adoption, agreement, acting on the suggestion, etc.). Assistant suggestions alone do not constitute user preferences.

Requirements:
1. Only make inferences when there is sufficient evidence in the conversation; avoid unsupported or far-fetched guesses.
Expand Down Expand Up @@ -117,6 +118,7 @@
* **情境信号**:用户的选择、比较、排除或场景选择揭示了什么样的深层偏好?
- 不要将明确陈述的偏好视为隐式偏好;此提示仅用于推断未直接提及的偏好。
- 超越表面事实,理解用户的隐藏可能性和背后的逻辑。
- 对于Assistant的回答内容或建议,只有在后续对话中用户表现出隐含接受(如采纳、认同、按建议行动等)的情况下,才能将相关内容提取为用户的隐式偏好。单纯的Assistant建议本身不构成用户偏好。

要求:
1. 仅在对话中有充分证据时进行推断;避免无根据或牵强的猜测。
Expand Down