Skip to content

Commit 177c826

Browse files
committed
Merge branch 'develop' into crone/ci-cd-pipline
2 parents 27ef7ce + 0d5bdcc commit 177c826

22 files changed

+3162
-1134
lines changed

ProjectVG.Application/Models/Chat/ChatProcessContext.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public record ChatProcessContext
99
public Guid UserId { get; private set; }
1010
public Guid CharacterId { get; private set; }
1111
public string UserMessage { get; private set; } = string.Empty;
12-
public string MemoryStore { get; private set; } = string.Empty;
1312
public DateTime UserRequestAt { get; private set; } = DateTime.Now;
1413
public bool UseTTS { get; private set; } = true;
1514

@@ -27,7 +26,6 @@ public ChatProcessContext(ChatRequestCommand command)
2726
UserId = command.UserId;
2827
CharacterId = command.CharacterId;
2928
UserMessage = command.UserPrompt;
30-
MemoryStore = command.UserId.ToString();
3129
UseTTS = command.UseTTS;
3230
UserRequestAt = command.UserRequestAt;
3331
}
@@ -42,7 +40,6 @@ public ChatProcessContext(
4240
UserId = command.UserId;
4341
CharacterId = command.CharacterId;
4442
UserMessage = command.UserPrompt;
45-
MemoryStore = command.UserId.ToString();
4643
UseTTS = command.UseTTS;
4744
UserRequestAt = command.UserRequestAt;
4845

@@ -63,11 +60,15 @@ public void AddCost(double additionalCost)
6360
Cost += additionalCost;
6461
}
6562

66-
public IEnumerable<string> ParseConversationHistory(int count = 5)
63+
public IEnumerable<ConversationHistory> ParseConversationHistory(int count = 10)
6764
{
68-
if (ConversationHistory == null) return Enumerable.Empty<string>();
65+
if (ConversationHistory == null)
66+
{
67+
return Enumerable.Empty<ConversationHistory>();
68+
}
6969

70-
return ConversationHistory.Take(count).Select(h => $"{h.Role}: {h.Content}");
70+
var parsed = ConversationHistory.Take(count);
71+
return parsed.ToList();
7172
}
7273

7374
public string ToDebugString()

ProjectVG.Application/Services/Chat/ChatService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ private async Task<ChatProcessContext> PrepareChatRequestAsync(ChatRequestComman
8989
await _actionProcessor.ProcessAsync(command);
9090

9191
var characterInfo = await _characterService.GetCharacterByIdAsync(command.CharacterId);
92-
var conversationHistoryContext = await _conversationService.GetConversationHistoryAsync(command.UserId, command.CharacterId, 10);
92+
93+
var conversationHistoryContext = await _conversationService.GetConversationHistoryAsync(command.UserId, command.CharacterId, 1, 10);
94+
9395
var memoryContext = await _memoryPreprocessor.CollectMemoryContextAsync(command);
9496

95-
96-
9797
return new ChatProcessContext(
9898
command,
9999
characterInfo,

ProjectVG.Application/Services/Chat/Processors/ChatLLMProcessor.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,20 @@ public async Task ProcessAsync(ChatProcessContext context)
2323
{
2424
var format = LLMFormatFactory.CreateChatFormat();
2525

26+
var conversationHistory = context.ParseConversationHistory()
27+
.Select(h => new ProjectVG.Infrastructure.Integrations.LLMClient.Models.History
28+
{
29+
Role = h.Role,
30+
Content = h.Content
31+
})
32+
.ToList();
33+
34+
2635
var llmResponse = await _llmClient.CreateTextResponseAsync(
2736
format.GetSystemMessage(context),
2837
context.UserMessage,
2938
format.GetInstructions(context),
30-
context.ParseConversationHistory().ToList(),
39+
conversationHistory,
3140
model: format.Model,
3241
maxTokens: format.MaxTokens,
3342
temperature: format.Temperature
@@ -37,8 +46,6 @@ public async Task ProcessAsync(ChatProcessContext context)
3746
var cost = format.CalculateCost(llmResponse.InputTokens, llmResponse.OutputTokens);
3847
context.SetResponse(llmResponse.OutputText, segments, cost);
3948

40-
_logger.LogInformation("채팅 처리 결과: {Response}\n 세그먼트 생성 개수: {SementCount}\n 입력 토큰: {InputTokens}\n 출력 토큰: {OutputTokens}\n 비용: {Cost}",
41-
llmResponse.OutputText, segments.Count, llmResponse.InputTokens, llmResponse.OutputTokens, cost);
4249
}
4350
}
4451
}

ProjectVG.Application/Services/Chat/Processors/ChatResultProcessor.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ public ChatResultProcessor(
2828

2929
public async Task PersistResultsAsync(ChatProcessContext context)
3030
{
31+
3132
await _conversationService.AddMessageAsync(context.UserId, context.CharacterId, ChatRole.User, context.UserMessage, context.UserRequestAt, context.RequestId.ToString());
33+
34+
3235
await _conversationService.AddMessageAsync(context.UserId, context.CharacterId, ChatRole.Assistant, context.Response, DateTime.UtcNow, context.RequestId.ToString());
36+
3337
await PersistMemoryAsync(context);
34-
35-
_logger.LogDebug("채팅 결과 저장 완료: 세션 {UserId}, 사용자 {UserId}", context.RequestId, context.UserId);
3638
}
3739

3840
private async Task PersistMemoryAsync(ChatProcessContext context)
@@ -89,7 +91,6 @@ private async Task PersistMemoryAsync(ChatProcessContext context)
8991
await _memoryClient.InsertEpisodicAsync(userMemoryRequest);
9092
await _memoryClient.InsertEpisodicAsync(episodicRequest);
9193

92-
_logger.LogDebug("메모리 삽입 성공: 사용자={UserId}, 캐릭터={CharacterId}", context.UserId, context.CharacterId);
9394
}
9495
catch (Exception ex)
9596
{

ProjectVG.Application/Services/Conversation/ConversationService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public ConversationService(IConversationRepository conversationRepository, ILogg
1919

2020
public async Task<ConversationHistory> AddMessageAsync(Guid userId, Guid characterId, string role, string content, DateTime timestamp, string? conversationId = null)
2121
{
22+
2223
if (string.IsNullOrWhiteSpace(content))
2324
{
2425
throw new ValidationException(ErrorCode.MESSAGE_EMPTY, content);
@@ -45,11 +46,13 @@ public async Task<ConversationHistory> AddMessageAsync(Guid userId, Guid charact
4546
};
4647

4748
var addedMessage = await _conversationRepository.AddAsync(message);
49+
4850
return addedMessage;
4951
}
5052

5153
public async Task<IEnumerable<ConversationHistory>> GetConversationHistoryAsync(Guid userId, Guid characterId, int page = 1, int pageSize = 10)
5254
{
55+
5356
if (page <= 0)
5457
{
5558
throw new ValidationException(ErrorCode.VALIDATION_FAILED, $"Page must be greater than 0, but was: {page}");
@@ -61,6 +64,7 @@ public async Task<IEnumerable<ConversationHistory>> GetConversationHistoryAsync(
6164
}
6265

6366
var history = await _conversationRepository.GetConversationHistoryAsync(userId, characterId, page, pageSize);
67+
6468
return history;
6569
}
6670

ProjectVG.Infrastructure/Integrations/LLMClient/ILLMClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Task<LLMResponse> CreateTextResponseAsync(
2626
string systemMessage,
2727
string userMessage,
2828
string? instructions = "",
29-
List<string>? conversationHistory = default,
29+
List<History>? conversationHistory = default,
3030
string? model = "gpt-4o-mini",
3131
int? maxTokens = 1000,
3232
float? temperature = 0.7f);

ProjectVG.Infrastructure/Integrations/LLMClient/LLMClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public async Task<LLMResponse> CreateTextResponseAsync(
6666
string systemMessage,
6767
string userMessage,
6868
string? instructions = "",
69-
List<string>? conversationHistory = default,
69+
List<History>? conversationHistory = default,
7070
string? model = "gpt-4o-mini",
7171
int? maxTokens = 1000,
7272
float? temperature = 0.7f)
@@ -76,7 +76,7 @@ public async Task<LLMResponse> CreateTextResponseAsync(
7676
SystemPrompt = systemMessage,
7777
UserPrompt = userMessage,
7878
Instructions = instructions ?? "",
79-
ConversationHistory = conversationHistory?.Select(msg => new History { Role = "user", Content = msg }).ToList() ?? new List<History>(),
79+
ConversationHistory = conversationHistory ?? new List<History>(),
8080
Model = model ?? "gpt-4o-mini",
8181
MaxTokens = maxTokens ?? 1000,
8282
Temperature = temperature ?? 0.7f,

ProjectVG.Infrastructure/Integrations/TextToSpeechClient/Models/TextToSpeechRequest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class VoiceSettings
4545
/// 피치 레벨을 조절합니다. 0은 원래 음성 피치이며, ±12단계가 가능합니다. 1단계는 반음입니다.
4646
/// </summary>
4747
[JsonPropertyName("pitch_shift")]
48-
public int PitchShift { get; set; } = 0;
48+
public int PitchShift { get; set; } = -3;
4949

5050
/// <summary>
5151
/// 음성 중 음조 변화의 정도를 조절합니다. 값이 작을수록 음조가 평탄해지고, 값이 클수록 음조가 풍부해집니다.
@@ -57,6 +57,6 @@ public class VoiceSettings
5757
/// 음성 속도를 조절합니다. 값이 1보다 작으면 음성 속도가 느려지고, 값이 1보다 크면 음성 속도가 빨라집니다.
5858
/// </summary>
5959
[JsonPropertyName("speed")]
60-
public float Speed { get; set; } = 1.2f;
60+
public float Speed { get; set; } = 1.1f;
6161
}
6262
}

0 commit comments

Comments
 (0)