From 40fb522f56796e01b41c86bd24c7ac6b0a766f03 Mon Sep 17 00:00:00 2001 From: takatost Date: Thu, 24 Oct 2024 02:34:10 -0700 Subject: [PATCH] add trace --- api/core/app/apps/advanced_chat/app_runner.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/api/core/app/apps/advanced_chat/app_runner.py b/api/core/app/apps/advanced_chat/app_runner.py index 65d744eddf..562bde9b53 100644 --- a/api/core/app/apps/advanced_chat/app_runner.py +++ b/api/core/app/apps/advanced_chat/app_runner.py @@ -1,4 +1,5 @@ import logging +import time from collections.abc import Mapping from typing import Any, cast @@ -101,6 +102,9 @@ class AdvancedChatAppRunner(WorkflowBasedAppRunner): ): return + # trace start time + start_time = time.perf_counter() + # Init conversation variables stmt = select(ConversationVariable).where( ConversationVariable.app_id == self.conversation.app_id, @@ -128,6 +132,13 @@ class AdvancedChatAppRunner(WorkflowBasedAppRunner): conversation_dialogue_count = self.conversation.dialogue_count db.session.commit() + # trace end time + end_time = time.perf_counter() + print(f"conversation_dialogue_count time: {end_time - start_time}") + + # trace start time + start_time = time.perf_counter() + # Create a variable pool. system_inputs = { SystemVariableKey.QUERY: query, @@ -151,6 +162,10 @@ class AdvancedChatAppRunner(WorkflowBasedAppRunner): # init graph graph = self._init_graph(graph_config=workflow.graph_dict) + # trace end time + end_time = time.perf_counter() + print(f"init graph time: {end_time - start_time}") + db.session.close() # RUN WORKFLOW