tests: add missing tests for streaming chat message
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user