Skip to content

Commit

Permalink
fix yield title issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcb committed Dec 24, 2024
1 parent a5d20c6 commit d996d53
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/BE/Controllers/Chats/Chats/ChatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public async Task<IActionResult> StartConversationStreamed(

// insert system message if it doesn't exist
List<MessageLiteDto> systemMessages = new(capacity: req.Spans.Length + 1);
if (existingMessages.Count == 0)
bool isEmptyChat = existingMessages.Count == 0;
if (isEmptyChat)
{
if (req.AllSystemPromptSame && req.Spans[0].SystemPromptValid)
{
Expand Down Expand Up @@ -187,6 +188,7 @@ public async Task<IActionResult> StartConversationStreamed(
{
db.Messages.Add(resp.AssistantMessage);
}
if (isEmptyChat) chat.Title = request.UserMessage!.Text[..Math.Min(50, request.UserMessage.Text.Length)];
await db.SaveChangesAsync(cancellationToken);

// yield end messages
Expand All @@ -213,11 +215,7 @@ public async Task<IActionResult> StartConversationStreamed(
}

// yield title
if (existingMessages.Count == 0)
{
chat.Title = request.UserMessage!.Text[..Math.Min(50, request.UserMessage.Text.Length)];
await YieldTitle(chat.Title);
}
if (isEmptyChat) await YieldTitle(chat.Title);
return new EmptyResult();
}

Expand Down

0 comments on commit d996d53

Please sign in to comment.