perf(logging): optimize debug logging in PromptChatMemoryAdvisor (#3448)
- Enclosed debug logging statements within an isDebugEnabled() check
- Reduced unnecessary method calls and object creations when debug logging is disabled
Signed-off-by: Ahoo Wang <ahoowang@qq.com>
(cherry picked from commit e45b1b3f8d)
This commit is contained in:
@@ -157,13 +157,18 @@ public final class PromptChatMemoryAdvisor implements BaseChatMemoryAdvisor {
|
||||
if (!assistantMessages.isEmpty()) {
|
||||
this.chatMemory.add(this.getConversationId(chatClientResponse.context(), this.defaultConversationId),
|
||||
assistantMessages);
|
||||
logger.debug("[PromptChatMemoryAdvisor.after] Added ASSISTANT messages to memory for conversationId={}: {}",
|
||||
this.getConversationId(chatClientResponse.context(), this.defaultConversationId),
|
||||
assistantMessages);
|
||||
List<Message> memoryMessages = this.chatMemory
|
||||
.get(this.getConversationId(chatClientResponse.context(), this.defaultConversationId));
|
||||
logger.debug("[PromptChatMemoryAdvisor.after] Memory after ASSISTANT add for conversationId={}: {}",
|
||||
this.getConversationId(chatClientResponse.context(), this.defaultConversationId), memoryMessages);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(
|
||||
"[PromptChatMemoryAdvisor.after] Added ASSISTANT messages to memory for conversationId={}: {}",
|
||||
this.getConversationId(chatClientResponse.context(), this.defaultConversationId),
|
||||
assistantMessages);
|
||||
List<Message> memoryMessages = this.chatMemory
|
||||
.get(this.getConversationId(chatClientResponse.context(), this.defaultConversationId));
|
||||
logger.debug("[PromptChatMemoryAdvisor.after] Memory after ASSISTANT add for conversationId={}: {}",
|
||||
this.getConversationId(chatClientResponse.context(), this.defaultConversationId),
|
||||
memoryMessages);
|
||||
}
|
||||
}
|
||||
return chatClientResponse;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user