Skip to content

Commit e8f46a5

Browse files
committed
feat: fix format
1 parent 272eee3 commit e8f46a5

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

src/memos/mem_os/product.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ def _send_message_to_scheduler(
524524
)
525525
self.mem_scheduler.submit_messages(messages=[message_item])
526526

527-
528527
async def _post_chat_processing(
529528
self,
530529
user_id: str,
@@ -541,16 +540,22 @@ async def _post_chat_processing(
541540
Asynchronous processing of logs, notifications and memory additions
542541
"""
543542
try:
544-
logger.info(f"user_id: {user_id}, cube_id: {cube_id}, current_messages: {current_messages}")
543+
logger.info(
544+
f"user_id: {user_id}, cube_id: {cube_id}, current_messages: {current_messages}"
545+
)
545546
logger.info(f"user_id: {user_id}, cube_id: {cube_id}, full_response: {full_response}")
546547

547-
clean_response, extracted_references = self._extract_references_from_response(full_response)
548+
clean_response, extracted_references = self._extract_references_from_response(
549+
full_response
550+
)
548551
logger.info(f"Extracted {len(extracted_references)} references from response")
549552

550553
# Send chat report notifications asynchronously
551554
if self.online_bot:
552555
try:
553-
from memos.memos_tools.notification_utils import send_online_bot_notification_async
556+
from memos.memos_tools.notification_utils import (
557+
send_online_bot_notification_async,
558+
)
554559

555560
# 准备通知数据
556561
chat_data = {
@@ -623,6 +628,7 @@ def _start_post_chat_processing(
623628
"""
624629
Asynchronous processing of logs, notifications and memory additions, handle synchronous and asynchronous environments
625630
"""
631+
626632
def run_async_in_thread():
627633
"""Running asynchronous tasks in a new thread"""
628634
try:
@@ -645,7 +651,10 @@ def run_async_in_thread():
645651
finally:
646652
loop.close()
647653
except Exception as e:
648-
logger.error(f"Error in thread-based post-chat processing for user {user_id}: {e}", exc_info=True)
654+
logger.error(
655+
f"Error in thread-based post-chat processing for user {user_id}: {e}",
656+
exc_info=True,
657+
)
649658

650659
try:
651660
# Try to get the current event loop
@@ -666,7 +675,10 @@ def run_async_in_thread():
666675
)
667676
# Add exception handling for the background task
668677
task.add_done_callback(
669-
lambda t: logger.error(f"Error in background post-chat processing for user {user_id}: {t.exception()}", exc_info=True)
678+
lambda t: logger.error(
679+
f"Error in background post-chat processing for user {user_id}: {t.exception()}",
680+
exc_info=True,
681+
)
670682
if t.exception()
671683
else None
672684
)
@@ -676,11 +688,10 @@ def run_async_in_thread():
676688
target=run_async_in_thread,
677689
name=f"PostChatProcessing-{user_id}",
678690
# Set as a daemon thread to avoid blocking program exit
679-
daemon=True
691+
daemon=True,
680692
)
681693
thread.start()
682694

683-
684695
def _filter_memories_by_threshold(
685696
self, memories: list[TextualMemoryItem], threshold: float = 0.50, min_num: int = 3
686697
) -> list[TextualMemoryItem]:

src/memos/memos_tools/notification_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Notification utilities for MemOS product.
33
"""
4+
45
import asyncio
56
import logging
67

@@ -87,7 +88,7 @@ async def send_online_bot_notification_async(
8788
other_data1=other_data1,
8889
other_data2=other_data2,
8990
emoji=emoji,
90-
)
91+
),
9192
)
9293

9394
logger.info(f"Online bot notification sent successfully (async): {header_name}")

0 commit comments

Comments
 (0)