Skip to content

Commit

Permalink
correct span request
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcb committed Dec 24, 2024
1 parent 062f72b commit 989c9fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/BE/Controllers/Chats/Chats/ChatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ public async Task<IActionResult> GeneralChat(
return BadRequest(ModelState);
}

if (req.SpanIds.Length == 0)
{
return BadRequest("Spans must be provided");
}

foreach (int spanId in req.SpanIds)
{
if (spanId >= byte.MinValue && spanId <= byte.MaxValue)
{
continue;
}
return BadRequest("Invalid span id");
}

// ensure request span id is unique
if (req.SpanIds.Distinct().Count() != req.SpanIds.Length)
{
Expand Down
4 changes: 2 additions & 2 deletions src/BE/Controllers/Chats/Chats/Dtos/FreshChatRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public override ChatRequest ToChatRequest()
public record GeneralChatRequest : BaseChatRequest
{
[JsonPropertyName("spanIds")]
public required byte[] SpanIds { get; init; }
public required int[] SpanIds { get; init; }

[JsonPropertyName("userMessage")]
public required MessageContentRequest UserMessage { get; init; }
Expand All @@ -80,7 +80,7 @@ public override ChatRequest ToChatRequest()
{
EncryptedChatId = EncryptedChatId,
EncryptedMessageId = ParentAssistantMessageId,
Spans = SpanIds.Select(x => new InternalChatSpanRequest() { Id = x }).ToArray(),
Spans = SpanIds.Select(x => new InternalChatSpanRequest() { Id = (byte)x }).ToArray(),
UserMessage = UserMessage
};
}
Expand Down

0 comments on commit 989c9fc

Please sign in to comment.