Skip to content

Commit f83c5d5

Browse files
authored
fix: playground chat bug (MemTensor#975)
## Description <!-- Please include a summary of the changes below; Fill in the issue number that this PR addresses (if applicable); Fill in the related MemOS-Docs repository issue or PR link (if applicable); Mention the person who will review this PR (if you know who it is); Replace (summary), (issue), (docs-issue-or-pr-link), and (reviewer) with the appropriate information. 请在下方填写更改的摘要; 填写此 PR 解决的问题编号(如果适用); 填写相关的 MemOS-Docs 仓库 issue 或 PR 链接(如果适用); 提及将审查此 PR 的人(如果您知道是谁); 替换 (summary)、(issue)、(docs-issue-or-pr-link) 和 (reviewer) 为适当的信息。 --> Summary: (summary) Fix: #(issue) Docs Issue/PR: (docs-issue-or-pr-link) Reviewer: @(reviewer) ## Checklist: - [ ] I have performed a self-review of my own code | 我已自行检查了自己的代码 - [ ] I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释 - [ ] I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常 - [ ] I have created related documentation issue/PR in [MemOS-Docs](https://github.com/MemTensor/MemOS-Docs) (if applicable) | 我已在 [MemOS-Docs](https://github.com/MemTensor/MemOS-Docs) 中创建了相关的文档 issue/PR(如果适用) - [ ] I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用) - [ ] I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人
2 parents 45d13d0 + b60ab92 commit f83c5d5

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/memos/api/handlers/chat_handler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def handle_chat_complete(self, chat_req: APIChatCompleteRequest) -> dict[str, An
110110
Raises:
111111
HTTPException: If chat fails
112112
"""
113+
self.logger.info(f"[ChatHandler] Chat Req is: {chat_req}")
113114
try:
114115
# Resolve readable cube IDs (for search)
115116
readable_cube_ids = chat_req.readable_cube_ids or [chat_req.user_id]
@@ -241,6 +242,7 @@ def handle_chat_stream(self, chat_req: ChatRequest) -> StreamingResponse:
241242
Raises:
242243
HTTPException: If stream initialization fails
243244
"""
245+
self.logger.info(f"[ChatHandler] Chat Req is: {chat_req}")
244246
try:
245247

246248
def generate_chat_response() -> Generator[str, None, None]:
@@ -422,6 +424,7 @@ def handle_chat_stream_playground(self, chat_req: ChatPlaygroundRequest) -> Stre
422424
Raises:
423425
HTTPException: If stream initialization fails
424426
"""
427+
self.logger.info(f"[ChatHandler] Chat Req is: {chat_req}")
425428
try:
426429

427430
def generate_chat_response() -> Generator[str, None, None]:
@@ -585,6 +588,8 @@ def generate_chat_response() -> Generator[str, None, None]:
585588
# get internet reference
586589
internet_reference = self._get_internet_reference(
587590
search_response.data.get("text_mem")[0]["memories"]
591+
if search_response.data.get("text_mem")
592+
else []
588593
)
589594
yield f"data: {json.dumps({'type': 'reference', 'data': reference}, ensure_ascii=False)}\n\n"
590595

src/memos/mem_reader/multi_modal_struct.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -464,13 +464,6 @@ def _get_maybe_merged_memory(
464464
status="activated",
465465
threshold=merge_threshold,
466466
user_name=user_name,
467-
filter={
468-
"or": [
469-
{"memory_type": "LongTermMemory"},
470-
{"memory_type": "UserMemory"},
471-
{"memory_type": "WorkingMemory"},
472-
]
473-
},
474467
)
475468

476469
if not search_results:

src/memos/mem_reader/read_multi_modal/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
TextualMemoryItem,
1616
TreeNodeTextualMemoryMetadata,
1717
)
18+
from memos.utils import timed
1819

1920
from .utils import detect_lang, get_text_splitter
2021

@@ -245,6 +246,7 @@ def parse(
245246
else:
246247
raise ValueError(f"Unknown mode: {mode}. Must be 'fast' or 'fine'")
247248

249+
@timed
248250
def _split_text(self, text: str, is_markdown: bool = False) -> list[str]:
249251
"""
250252
Split text into chunks using text splitter from utils.

0 commit comments

Comments
 (0)