tests: add missing tests for streaming chat message

This commit is contained in:
Stevan Freeborn
2024-06-29 22:07:49 -05:00
parent 77ceb49c77
commit 5edc0b5fff
16 changed files with 1183 additions and 7 deletions
+8 -1
View File
@@ -172,6 +172,13 @@ public class AnthropicApiClient : IAnthropicApiClient
chatResponse is not null
)
{
var existingUsage = chatResponse.Usage;
var newUsage = new ChatUsage()
{
InputTokens = existingUsage.InputTokens + msgDeltaData.Usage.InputTokens,
OutputTokens = existingUsage.OutputTokens + msgDeltaData.Usage.OutputTokens,
};
chatResponse = new ChatResponse()
{
Id = chatResponse.Id,
@@ -180,7 +187,7 @@ public class AnthropicApiClient : IAnthropicApiClient
StopReason = msgDeltaData.Delta.StopReason,
StopSequence = msgDeltaData.Delta.StopSequence,
Type = chatResponse.Type,
Usage = msgDeltaData.Usage,
Usage = newUsage,
Content = chatResponse.Content,
};
}
-2
View File
@@ -1,5 +1,3 @@
using System.Text.Json.Serialization;
namespace AnthropicClient.Models;
public abstract class EventData
@@ -1,11 +1,9 @@
using System.Text.Json.Serialization;
namespace AnthropicClient.Models;
public class MessageCompleteEventData : EventData
{
public AnthropicHeaders Headers { get; init; } = new();
public ChatResponse Message { get; init; } = new();
public AnthropicHeaders Headers { get; init; }
public ChatResponse Message { get; init; }
public MessageCompleteEventData(ChatResponse message, AnthropicHeaders headers) : base(EventType.MessageComplete)
{