|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.Diagnostics;
namespace Microsoft.Extensions.AI;
/// <summary>Provides usage details about a request/response.</summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class UsageDetails
{
/// <summary>Gets or sets the number of tokens in the input.</summary>
public int? InputTokenCount { get; set; }
/// <summary>Gets or sets the number of tokens in the output.</summary>
public int? OutputTokenCount { get; set; }
/// <summary>Gets or sets the total number of tokens used to produce the response.</summary>
public int? TotalTokenCount { get; set; }
/// <summary>Gets or sets additional properties for the usage details.</summary>
public AdditionalPropertiesDictionary? AdditionalProperties { get; set; }
/// <summary>Gets a string representing this instance to display in the debugger.</summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
internal string DebuggerDisplay
{
get
{
List<string> parts = [];
if (InputTokenCount is int input)
{
parts.Add($"{nameof(InputTokenCount)} = {input}");
}
if (OutputTokenCount is int output)
{
parts.Add($"{nameof(OutputTokenCount)} = {output}");
}
if (TotalTokenCount is int total)
{
parts.Add($"{nameof(TotalTokenCount)} = {total}");
}
if (AdditionalProperties is { } additionalProperties)
{
foreach (var entry in additionalProperties)
{
parts.Add($"{entry.Key} = {entry.Value}");
}
}
return string.Join(", ", parts);
}
}
}
|