Skip to content

Commit 12e4358

Browse files
authored
.Net: Added fix for null completion usage details (#4956)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Resolves: #4953 ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
1 parent dc5a0e3 commit 12e4358

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

dotnet/src/Connectors/Connectors.OpenAI/AzureSdk/ClientCore.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,16 @@ private static async Task<T> RunRequestAsync<T>(Func<Task<T>> request)
10001000
/// <param name="usage">Instance of <see cref="CompletionsUsage"/> with usage details.</param>
10011001
private void CaptureUsageDetails(CompletionsUsage usage)
10021002
{
1003+
if (usage is null)
1004+
{
1005+
if (this.Logger.IsEnabled(LogLevel.Debug))
1006+
{
1007+
this.Logger.LogDebug("Usage information is not available.");
1008+
}
1009+
1010+
return;
1011+
}
1012+
10031013
if (this.Logger.IsEnabled(LogLevel.Information))
10041014
{
10051015
this.Logger.LogInformation(

0 commit comments

Comments
 (0)