13 instantiations of UsageContent
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
259response.Message.Contents = [.. response.Message.Contents, new UsageContent(usage)];
Microsoft.Extensions.AI.Abstractions (1)
ChatCompletion\ChatCompletion.cs (1)
124extra.Contents.Add(new UsageContent(usage));
Microsoft.Extensions.AI.Abstractions.Tests (7)
ChatCompletion\StreamingChatCompletionUpdateExtensionsTests.cs (3)
50new() { ChoiceIndex = 0, Contents = new[] { new UsageContent(new() { InputTokenCount = 1, OutputTokenCount = 2 }) } }, 51new() { ChoiceIndex = 3, Contents = new[] { new UsageContent(new() { InputTokenCount = 4, OutputTokenCount = 5 }) } }, 199new() { Contents = [new UsageContent(new() { TotalTokenCount = 42 })] },
Contents\UsageContentTests.cs (4)
14Assert.Throws<ArgumentNullException>("details", () => new UsageContent(null!)); 20UsageContent c = new(); 37UsageContent c = new(details); 51UsageContent c = new();
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceChatClient.cs (1)
216completionUpdate.Contents.Add(new UsageContent(new()
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
168update.Contents.Add(new UsageContent(usage));
Microsoft.Extensions.AI.OpenAI (1)
OpenAIChatClient.cs (1)
310completionUpdate.Contents.Add(new UsageContent(usageDetails));
Microsoft.Extensions.AI.Tests (1)
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
80Contents = [new UsageContent(new()
19 references to UsageContent
Microsoft.Extensions.AI.Abstractions (4)
ChatCompletion\StreamingChatCompletionUpdateExtensions.cs (1)
170if (content is UsageContent c)
Contents\AIContent.cs (1)
16[JsonDerivedType(typeof(UsageContent), typeDiscriminator: "usage")]
Contents\UsageContent.cs (2)
19/// <summary>Initializes a new instance of the <see cref="UsageContent"/> class with an empty <see cref="UsageDetails"/>.</summary> 25/// <summary>Initializes a new instance of the <see cref="UsageContent"/> class with the specified <see cref="UsageDetails"/> instance.</summary>
Microsoft.Extensions.AI.Abstractions.Tests (5)
ChatCompletion\ChatCompletionTests.cs (1)
295Assert.Equal(123, Assert.IsType<UsageContent>(Assert.Single(update2.Contents)).Details.TotalTokenCount);
ChatCompletion\StreamingChatCompletionUpdateExtensionsTests.cs (1)
67Assert.Same(Assert.IsType<UsageContent>(updates[6].Contents[0]).Details, completion.Usage);
Contents\UsageContentTests.cs (3)
20UsageContent c = new(); 37UsageContent c = new(details); 51UsageContent c = new();
Microsoft.Extensions.AI.Integration.Tests (4)
ChatClientIntegrationTests.cs (4)
132UsageContent usage = chunks.SelectMany(c => c.Contents).OfType<UsageContent>().Single(); 183UsageContent? intermediate = messages.SelectMany(m => m.Contents).OfType<UsageContent>().FirstOrDefault();
Microsoft.Extensions.AI.Ollama.Tests (2)
OllamaChatClientTests.cs (2)
198UsageContent usage = Assert.IsType<UsageContent>(updates[updates.Count - 1].Contents[1]);
Microsoft.Extensions.AI.OpenAI.Tests (4)
OpenAIChatClientTests.cs (4)
274UsageContent usage = updates.SelectMany(u => u.Contents).OfType<UsageContent>().Single(); 781UsageContent usage = updates.SelectMany(u => u.Contents).OfType<UsageContent>().Single();