4 writes to Usage
Microsoft.Extensions.AI (1)
ChatCompletion\ChatCompletion{T}.cs (1)
41Usage = completion.Usage;
Microsoft.Extensions.AI.Abstractions (1)
ChatCompletion\StreamingChatCompletionUpdateExtensions.cs (1)
172completion.Usage = c.Details;
Microsoft.Extensions.AI.Abstractions.Tests (1)
ChatCompletion\ChatCompletionTests.cs (1)
107completion.Usage = usage;
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceChatClient.cs (1)
140Usage = usage,
52 references to Usage
Microsoft.Extensions.AI (5)
ChatCompletion\ChatCompletion{T}.cs (1)
41Usage = completion.Usage;
ChatCompletion\FunctionInvokingChatClient.cs (1)
257if (KeepFunctionCallingMessages && response.Usage is { } usage)
ChatCompletion\OpenTelemetryChatClient.cs (3)
320if (_tokenUsageHistogram.Enabled && completion?.Usage is { } usage) 369if (completion.Usage?.InputTokenCount is int inputTokens) 374if (completion.Usage?.OutputTokenCount is int outputTokens)
Microsoft.Extensions.AI.Abstractions (3)
ChatCompletion\ChatCompletion.cs (2)
115if (AdditionalProperties is not null || Usage is not null) 122if (Usage is { } usage)
ChatCompletion\StreamingChatCompletionUpdateExtensions.cs (1)
166if (completion.Usage is null)
Microsoft.Extensions.AI.Abstractions.Tests (6)
ChatCompletion\ChatCompletionTests.cs (3)
105Assert.Null(completion.Usage); 108Assert.Same(usage, completion.Usage); 162Assert.NotNull(result.Usage);
ChatCompletion\StreamingChatCompletionUpdateExtensionsTests.cs (3)
67Assert.Same(Assert.IsType<UsageContent>(updates[6].Contents[0]).Details, completion.Usage); 206Assert.NotNull(completion.Usage); 207Assert.Equal(42, completion.Usage.TotalTokenCount);
Microsoft.Extensions.AI.AzureAIInference.Tests (8)
AzureAIInferenceChatClientTests.cs (8)
155Assert.NotNull(response.Usage); 156Assert.Equal(8, response.Usage.InputTokenCount); 157Assert.Equal(9, response.Usage.OutputTokenCount); 158Assert.Equal(17, response.Usage.TotalTokenCount); 417Assert.NotNull(response.Usage); 418Assert.Equal(42, response.Usage.InputTokenCount); 419Assert.Equal(15, response.Usage.OutputTokenCount); 420Assert.Equal(57, response.Usage.TotalTokenCount);
Microsoft.Extensions.AI.Integration.Tests (5)
ChatClientIntegrationTests.cs (5)
106Assert.True(response.Usage?.InputTokenCount > 1); 107Assert.True(response.Usage?.OutputTokenCount > 1); 108Assert.Equal(response.Usage?.InputTokenCount + response.Usage?.OutputTokenCount, response.Usage?.TotalTokenCount);
Microsoft.Extensions.AI.Ollama.Tests (4)
OllamaChatClientTests.cs (4)
126Assert.NotNull(response.Usage); 127Assert.Equal(11, response.Usage.InputTokenCount); 128Assert.Equal(10, response.Usage.OutputTokenCount); 129Assert.Equal(21, response.Usage.TotalTokenCount);
Microsoft.Extensions.AI.OpenAI.Tests (20)
OpenAIChatClientTests.cs (20)
198Assert.NotNull(response.Usage); 199Assert.Equal(8, response.Usage.InputTokenCount); 200Assert.Equal(9, response.Usage.OutputTokenCount); 201Assert.Equal(17, response.Usage.TotalTokenCount); 202Assert.NotNull(response.Usage.AdditionalProperties); 471Assert.NotNull(response.Usage); 472Assert.Equal(42, response.Usage.InputTokenCount); 473Assert.Equal(15, response.Usage.OutputTokenCount); 474Assert.Equal(57, response.Usage.TotalTokenCount); 475Assert.NotNull(response.Usage.AdditionalProperties); 564Assert.NotNull(response.Usage); 565Assert.Equal(42, response.Usage.InputTokenCount); 566Assert.Equal(15, response.Usage.OutputTokenCount); 567Assert.Equal(57, response.Usage.TotalTokenCount); 568Assert.NotNull(response.Usage.AdditionalProperties); 915Assert.NotNull(response.Usage); 916Assert.Equal(42, response.Usage.InputTokenCount); 917Assert.Equal(15, response.Usage.OutputTokenCount); 918Assert.Equal(57, response.Usage.TotalTokenCount); 919Assert.NotNull(response.Usage.AdditionalProperties);
Microsoft.Extensions.AI.Tests (1)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (1)
67Assert.Same(expectedCompletion.Usage, response.Usage);