Skip to content

Commit c11d486

Browse files
More code review feedback
1 parent cb46cca commit c11d486

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

dotnet/src/Agents/OpenAI/Extensions/KernelExtensions.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
using System;
33
using System.Diagnostics.CodeAnalysis;
44
using System.Linq;
5-
using System.Net.Http;
65
using Azure.AI.OpenAI;
76
using Azure.Identity;
8-
using Microsoft.Extensions.DependencyInjection;
7+
using Microsoft.SemanticKernel.Http;
98
using OpenAI;
109

1110
namespace Microsoft.SemanticKernel.Agents.OpenAI;
@@ -39,7 +38,9 @@ public static OpenAIClient GetOpenAIClient(this Kernel kernel, AgentDefinition a
3938
throw new InvalidOperationException("OpenAI client type must be specified.");
4039
}
4140

42-
var httpClient = kernel.Services.GetService<HttpClient>();
41+
#pragma warning disable CA2000 // Dispose objects before losing scope, not applicable because the HttpClient is created elsewhere
42+
var httpClient = HttpClientProvider.GetHttpClient(kernel.Services);
43+
#pragma warning restore CA2000 // Dispose objects before losing scope
4344
if (configuration.Type.Equals(OpenAI, StringComparison.OrdinalIgnoreCase))
4445
{
4546
OpenAIClientOptions clientOptions = OpenAIClientProvider.CreateOpenAIClientOptions(configuration.GetEndpointUri(), httpClient);

0 commit comments

Comments
 (0)