You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: EssentialCSharp.Chat.Shared/Extensions/ServiceCollectionExtensions.cs
+13-30Lines changed: 13 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -22,14 +22,12 @@ public static class ServiceCollectionExtensions
22
22
/// <param name="aiOptions">The AI configuration options</param>
23
23
/// <param name="postgresConnectionString">The PostgreSQL connection string for the vector store</param>
24
24
/// <param name="credential">The token credential to use for authentication. If null, DefaultAzureCredential will be used.</param>
25
-
/// <param name="configureResilience">Whether to configure HTTP resilience for all HTTP clients. Default is true. Set to false if you want to configure resilience separately.</param>
26
25
/// <returns>The service collection for chaining</returns>
// Use DefaultAzureCredential if no credential is provided
35
33
// This works both locally (using Azure CLI, Visual Studio, etc.) and in Azure (using Managed Identity)
@@ -42,11 +40,8 @@ public static IServiceCollection AddAzureOpenAIServices(
42
40
43
41
varendpoint=newUri(aiOptions.Endpoint);
44
42
45
-
// Configure HTTP resilience for Azure OpenAI requests if requested
46
-
if(configureResilience)
47
-
{
48
-
ConfigureAzureOpenAIResilience(services);
49
-
}
43
+
// Configure HTTP resilience for Azure OpenAI requests
44
+
ConfigureAzureOpenAIResilience(services);
50
45
51
46
// Register Azure OpenAI services with Managed Identity authentication
52
47
#pragma warning disable SKEXP0010// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
@@ -88,11 +83,6 @@ public static IServiceCollection AddAzureOpenAIServices(
88
83
/// <param name="services">The service collection to configure</param>
89
84
/// <remarks>
90
85
/// This method configures resilience for ALL HTTP clients created via IHttpClientFactory.
91
-
/// This is appropriate when your application ONLY uses Azure OpenAI HTTP clients.
92
-
///
93
-
/// If your application has other HTTP clients (e.g., third-party APIs) that shouldn't
94
-
/// have the same retry behavior, set configureResilience=false when calling
95
-
/// AddAzureOpenAIServices and configure resilience on a per-client basis instead.
96
86
///
97
87
/// IMPORTANT: The Semantic Kernel's AddAzureOpenAI* extension methods (used in this class)
98
88
/// do NOT expose options to configure specific named or typed HttpClients. The internal
@@ -105,15 +95,15 @@ public static IServiceCollection AddAzureOpenAIServices(
105
95
/// - Respects Retry-After headers from Azure OpenAI
106
96
/// - Uses exponential backoff with jitter
107
97
/// - Implements circuit breaker pattern
98
+
///
99
+
/// This is appropriate for applications that primarily use Azure OpenAI services.
100
+
/// The retry policies are reasonable for most HTTP APIs and should not negatively
101
+
/// impact other HTTP clients like hCaptcha or Mailjet.
/// <param name="services">The service collection to add services to</param>
152
142
/// <param name="configuration">The configuration to read AIOptions from</param>
153
143
/// <param name="credential">Optional token credential to use for authentication. If null, DefaultAzureCredential will be used.</param>
154
-
/// <param name="configureResilience">Whether to configure HTTP resilience for all HTTP clients. Default is true. Set to false if you want to configure resilience separately.</param>
155
144
/// <returns>The service collection for chaining</returns>
/// <param name="aiOptions">The AI configuration options</param>
240
228
/// <param name="postgresConnectionString">The PostgreSQL connection string for the vector store</param>
241
229
/// <param name="apiKey">The API key for Azure OpenAI authentication</param>
242
-
/// <param name="configureResilience">Whether to configure HTTP resilience for all HTTP clients. Default is true. Set to false if you want to configure resilience separately.</param>
243
230
/// <returns>The service collection for chaining</returns>
244
231
[Obsolete("API key authentication is not recommended for production. Use AddAzureOpenAIServices with Managed Identity instead.")]
@@ -261,11 +247,8 @@ public static IServiceCollection AddAzureOpenAIServicesWithApiKey(
261
247
262
248
varendpoint=newUri(aiOptions.Endpoint);
263
249
264
-
// Configure HTTP resilience for Azure OpenAI requests if requested
265
-
if(configureResilience)
266
-
{
267
-
ConfigureAzureOpenAIResilience(services);
268
-
}
250
+
// Configure HTTP resilience for Azure OpenAI requests
251
+
ConfigureAzureOpenAIResilience(services);
269
252
270
253
// Register Azure OpenAI services with API key authentication
271
254
#pragma warning disable SKEXP0010// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
0 commit comments