Added the exact token count for Anthropic and OpenAI (#1004)
Build and Release / Determine run mode (push) Has been cancelled
Build and Release / Verify (push) Has been cancelled
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Sync Flatpak repo (push) Has been cancelled
Build and Release / Collect Flatpak artifacts (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-09-24 13:36:06 +02:00
1 parent 0c585144e2
commit 4baf21656a
25 files changed
+837 -51

No files matched your search

@@ -218,7 +218,40 @@ public sealed class AnthropicMessageStreamAccumulatorTests
Assert.That(response, Is.Null, "An unfinished message is not handed on as if it were finished.");
}
[Test]
public void TheMessageStartStatesWhatTheRequestCarried()
{
const string MESSAGE_START = """{"type":"message_start","message":{"id":"msg_1","type":"message","role":"assistant","model":"claude-opus-5-5","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":2679,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":3}}}""";
var part = new AnthropicMessageStreamAccumulator().Process(Event(MESSAGE_START));
var response = Read(
MESSAGE_START,
"""{"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}""",
"""{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello."}}""",
"""{"type":"content_block_stop","index":0}""",
"""{"type":"message_stop"}""");
Assert.Multiple(() =>
{
Assert.That(part.Usage.PromptTokens, Is.EqualTo(2679), "The start of the message states what the request carried.");
Assert.That(part.HasContent, Is.False, "And it has nothing to show.");
Assert.That(response!.Content, Has.Count.EqualTo(1), "Nor does it become a block of the message.");
});
}
[Test]
public void TheMessageDeltaStatesNothingAboutTheRequest()
{
//
// Its usage is cumulative and holds whatever a server tool fed back into the same request.
//
var part = new AnthropicMessageStreamAccumulator().Process(Event(
"""{"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"input_tokens":10682,"output_tokens":510}}"""));
Assert.That(part.Usage.IsKnown, Is.False);
}
private static AnthropicResponse? Read(params string[] data)
{
var accumulator = new AnthropicMessageStreamAccumulator();