|
12 | 12 | using Microsoft.SemanticKernel.Memory; |
13 | 13 | using Microsoft.SemanticKernel.Connectors.Qdrant; |
14 | 14 | using Microsoft.SemanticKernel.Connectors.OpenAI; |
| 15 | +using System.Configuration; |
15 | 16 |
|
16 | 17 | var builder = WebApplication.CreateBuilder(args); |
17 | 18 | builder.Services.AddSingleton<WebhookEventProcessor, GithubWebHookProcessor>(); |
|
41 | 42 | builder.Services.AddOptions<GithubOptions>() |
42 | 43 | .Configure<IConfiguration>((settings, configuration) => |
43 | 44 | { |
44 | | - configuration.GetSection("GithubOptions").Bind(settings); |
45 | | - }); |
| 45 | + configuration.GetSection(nameof(GithubOptions)).Bind(settings); |
| 46 | + }) |
| 47 | + .ValidateDataAnnotations() |
| 48 | + .ValidateOnStart(); |
| 49 | + |
46 | 50 | builder.Services.AddOptions<AzureOptions>() |
47 | 51 | .Configure<IConfiguration>((settings, configuration) => |
48 | 52 | { |
49 | | - configuration.GetSection("AzureOptions").Bind(settings); |
50 | | - }); |
| 53 | + configuration.GetSection(nameof(AzureOptions)).Bind(settings); |
| 54 | + }) |
| 55 | + .ValidateDataAnnotations() |
| 56 | + .ValidateOnStart(); |
| 57 | + |
51 | 58 | builder.Services.AddOptions<OpenAIOptions>() |
52 | 59 | .Configure<IConfiguration>((settings, configuration) => |
53 | 60 | { |
54 | | - configuration.GetSection("OpenAIOptions").Bind(settings); |
55 | | - }); |
| 61 | + configuration.GetSection(nameof(OpenAIOptions)).Bind(settings); |
| 62 | + }) |
| 63 | + .ValidateDataAnnotations() |
| 64 | + .ValidateOnStart(); |
| 65 | + |
56 | 66 | builder.Services.AddOptions<QdrantOptions>() |
57 | 67 | .Configure<IConfiguration>((settings, configuration) => |
58 | 68 | { |
59 | | - configuration.GetSection("QdrantOptions").Bind(settings); |
60 | | - }); |
| 69 | + configuration.GetSection(nameof(QdrantOptions)).Bind(settings); |
| 70 | + }) |
| 71 | + .ValidateDataAnnotations() |
| 72 | + .ValidateOnStart(); |
| 73 | + |
61 | 74 | builder.Services.AddOptions<ServiceOptions>() |
62 | 75 | .Configure<IConfiguration>((settings, configuration) => |
63 | 76 | { |
64 | | - configuration.GetSection("ServiceOptions").Bind(settings); |
65 | | - }); |
| 77 | + configuration.GetSection(nameof(ServiceOptions)).Bind(settings); |
| 78 | + }) |
| 79 | + .ValidateDataAnnotations() |
| 80 | + .ValidateOnStart(); |
66 | 81 |
|
67 | 82 | builder.Services.AddSingleton<IManageAzure, AzureService>(); |
68 | 83 | builder.Services.AddSingleton<IManageGithub, GithubService>(); |
69 | 84 | builder.Services.AddSingleton<IAnalyzeCode, CodeAnalyzer>(); |
70 | 85 |
|
71 | | - |
72 | 86 | builder.Host.UseOrleans(siloBuilder => |
73 | 87 | { |
74 | 88 |
|
|
91 | 105 | .UseEndpoints(endpoints => |
92 | 106 | { |
93 | 107 | var ghOptions = app.Services.GetService<IOptions<GithubOptions>>().Value; |
94 | | - endpoints.MapGitHubWebhooks(secret: ghOptions.WebhookSecret ); |
| 108 | + endpoints.MapGitHubWebhooks(secret: ghOptions.WebhookSecret); |
95 | 109 | }); |
96 | 110 |
|
97 | 111 | app.Map("/dashboard", x => x.UseOrleansDashboard()); |
@@ -125,11 +139,12 @@ static Kernel CreateKernel(IServiceProvider provider) |
125 | 139 | clientOptions.Retry.NetworkTimeout = TimeSpan.FromMinutes(5); |
126 | 140 | var openAIClient = new OpenAIClient(new Uri(openAiConfig.Endpoint), new AzureKeyCredential(openAiConfig.ApiKey), clientOptions); |
127 | 141 | var builder = Kernel.CreateBuilder(); |
128 | | - builder.Services.AddLogging( c=> c.AddConsole().AddDebug().SetMinimumLevel(LogLevel.Debug)); |
| 142 | + builder.Services.AddLogging(c => c.AddConsole().AddDebug().SetMinimumLevel(LogLevel.Debug)); |
129 | 143 | builder.Services.AddAzureOpenAIChatCompletion(openAiConfig.DeploymentOrModelId, openAIClient); |
130 | | - builder.Services.ConfigureHttpClientDefaults(c=> |
| 144 | + builder.Services.ConfigureHttpClientDefaults(c => |
131 | 145 | { |
132 | | - c.AddStandardResilienceHandler().Configure( o=> { |
| 146 | + c.AddStandardResilienceHandler().Configure(o => |
| 147 | + { |
133 | 148 | o.Retry.MaxRetryAttempts = 5; |
134 | 149 | o.Retry.BackoffType = Polly.DelayBackoffType.Exponential; |
135 | 150 | }); |
|
0 commit comments