Skip to content

Commit cf3734f

Browse files
committed
feat: LLM 처리 정보 출력
1 parent 28badc7 commit cf3734f

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

ProjectVG.Application/Models/Chat/ChatPreprocessContext.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using Microsoft.Extensions.Logging;
2+
13
namespace ProjectVG.Application.Models.Chat
24
{
35
public class ChatPreprocessContext
@@ -15,5 +17,40 @@ public class ChatPreprocessContext
1517

1618
public string MemoryStore { get; set; } = string.Empty;
1719
public string VoiceName { get; set; } = string.Empty;
20+
21+
public override string ToString()
22+
{
23+
return $"ChatPreprocessContext(SessionId={SessionId}, UserId={UserId}, CharacterId={CharacterId}, UserMessage='{UserMessage}', MemoryContext.Count={MemoryContext.Count}, ConversationHistory.Count={ConversationHistory.Count})";
24+
}
25+
26+
public string GetDetailedInfo()
27+
{
28+
var info = new System.Text.StringBuilder();
29+
info.AppendLine("=== ChatPreprocessContext ===");
30+
info.AppendLine($"SessionId: {SessionId}");
31+
info.AppendLine($"UserId: {UserId}");
32+
info.AppendLine($"CharacterId: {CharacterId}");
33+
info.AppendLine($"Action: {Action ?? "N/A"}");
34+
info.AppendLine($"VoiceName: {VoiceName}");
35+
info.AppendLine($"MemoryStore: {MemoryStore}");
36+
info.AppendLine($"UserMessage: {UserMessage}");
37+
info.AppendLine($"SystemMessage: {SystemMessage}");
38+
info.AppendLine($"Instructions: {Instructions}");
39+
40+
info.AppendLine($"MemoryContext ({MemoryContext.Count} items):");
41+
for (int i = 0; i < MemoryContext.Count; i++)
42+
{
43+
info.AppendLine($" [{i}]: {MemoryContext[i]}");
44+
}
45+
46+
info.AppendLine($"ConversationHistory ({ConversationHistory.Count} items):");
47+
for (int i = 0; i < ConversationHistory.Count; i++)
48+
{
49+
info.AppendLine($" [{i}]: {ConversationHistory[i]}");
50+
}
51+
info.AppendLine("=== End ChatPreprocessContext ===");
52+
53+
return info.ToString();
54+
}
1855
}
1956
}

ProjectVG.Application/Services/Chat/Core/ChatPreprocessor.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,13 @@ public async Task<ChatPreprocessContext> PreprocessAsync(ProcessChatCommand comm
4343
.CollectConversationHistoryAsync(command.UserId, command.CharacterId);
4444

4545
// todo : 지정된 캐릭터 설정 불러오기
46-
4746
CharacterDto? characterDto = await _characterService.GetCharacterByIdAsync(command.CharacterId);
4847

4948
// 프롬포트 설정
5049
var systemMessage = _systemPromptGenerator.Generate(characterDto);
5150
var instructions = _instructionGenerator.Generate();
5251

53-
54-
// todo : 시스템 프롬포트 작성 (캐릭터 설정에 맞게 작성)
55-
return new ChatPreprocessContext {
52+
var context = new ChatPreprocessContext {
5653
SessionId = command.SessionId,
5754
UserId = command.UserId,
5855
CharacterId = command.CharacterId,
@@ -65,6 +62,12 @@ public async Task<ChatPreprocessContext> PreprocessAsync(ProcessChatCommand comm
6562
ConversationHistory = conversationHistory,
6663
VoiceName = characterDto.VoiceId,
6764
};
65+
66+
// 컨텍스트 내용 출력
67+
_logger.LogInformation("Preprocess 완료: {Context}", context);
68+
_logger.LogInformation("상세 정보:\n{DetailedInfo}", context.GetDetailedInfo());
69+
70+
return context;
6871
}
6972
}
7073
}

0 commit comments

Comments
 (0)