From eacd7393c3169d826516542211177aa2de7a2da9 Mon Sep 17 00:00:00 2001 From: "liuchangsheng@wisdomidata.com" Date: Wed, 25 Jun 2025 15:21:39 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90Dify=E3=80=91=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E8=AF=AD=E5=8F=A5=EF=BC=8C=E6=8E=92=E6=9F=A5?= =?UTF-8?q?BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/services/message_service.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/api/services/message_service.py b/api/services/message_service.py index 51b070ece7..1d8cf55b8c 100644 --- a/api/services/message_service.py +++ b/api/services/message_service.py @@ -1,6 +1,6 @@ import json from typing import Optional, Union - +import time from core.app.apps.advanced_chat.app_config_manager import AdvancedChatAppConfigManager from core.app.entities.app_invoke_entities import InvokeFrom from core.llm_generator.llm_generator import LLMGenerator @@ -40,11 +40,12 @@ class MessageService: if not conversation_id: return InfiniteScrollPagination(data=[], limit=limit, has_more=False) - + start_time = time.time() conversation = ConversationService.get_conversation( app_model=app_model, user=user, conversation_id=conversation_id ) - + end_time = time.time() + print(f"-----------time1:{end_time - start_time} ") fetch_limit = limit + 1 if first_id: @@ -53,7 +54,8 @@ class MessageService: .filter(Message.conversation_id == conversation.id, Message.id == first_id) .first() ) - + end_time_2 = time.time() + print(f"-----------time-first_message:{end_time_2 - end_time} ") if not first_message: raise FirstMessageNotExistsError() @@ -68,6 +70,8 @@ class MessageService: .limit(fetch_limit) .all() ) + end_time_3 = time.time() + print(f"-----------time-history_messages:{end_time_3 - end_time_2} ") else: history_messages = ( db.session.query(Message) @@ -76,6 +80,8 @@ class MessageService: .limit(fetch_limit) .all() ) + end_time_3 = time.time() + print(f"-----------time-history_messages:{end_time_3 - end_time} ") has_more = False if len(history_messages) > limit: