diff --git a/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/AzureOptions.cs b/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/AzureOptions.cs index ccc21a31a..e3780a6a0 100644 --- a/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/AzureOptions.cs +++ b/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/AzureOptions.cs @@ -1,13 +1,22 @@ +using System.ComponentModel.DataAnnotations; + namespace Microsoft.AI.DevTeam; public class AzureOptions { + [Required] public string SubscriptionId { get; set; } + [Required] public string Location { get; set; } + [Required] public string ContainerInstancesResourceGroup { get; set; } + [Required] public string FilesShareName { get; set; } + [Required] public string FilesAccountName { get; set; } + [Required] public string FilesAccountKey { get; set; } - public string CosmosConnectionString { get; set; } + [Required] public string SandboxImage { get; set; } public string ManagedIdentity { get; set; } + public string CosmosConnectionString { get; set; } } \ No newline at end of file diff --git a/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/GithubOptions.cs b/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/GithubOptions.cs index f1e467de9..c13fc1e67 100644 --- a/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/GithubOptions.cs +++ b/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/GithubOptions.cs @@ -1,8 +1,14 @@ +using System.ComponentModel.DataAnnotations; + namespace Microsoft.AI.DevTeam; public class GithubOptions { + [Required] public string AppKey { get; set; } + [Required] public int AppId { get; set; } + [Required] public long InstallationId { get; set; } + [Required] public string WebhookSecret { get; set; } } \ No newline at end of file diff --git a/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/OpenAIOptions.cs b/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/OpenAIOptions.cs index df2b04b46..1b251c1fb 100644 --- a/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/OpenAIOptions.cs +++ b/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/OpenAIOptions.cs @@ -1,10 +1,18 @@ +using System.ComponentModel.DataAnnotations; + namespace Microsoft.AI.DevTeam; public class OpenAIOptions { + [Required] public string ServiceType { get; set; } + [Required] public string ServiceId { get; set; } + [Required] public string DeploymentOrModelId { get; set; } + [Required] public string EmbeddingDeploymentOrModelId { get; set; } + [Required] public string Endpoint { get; set; } + [Required] public string ApiKey { get; set; } } diff --git a/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/QdrantOptions.cs b/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/QdrantOptions.cs index 7fe3e9efe..da292ce62 100644 --- a/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/QdrantOptions.cs +++ b/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/QdrantOptions.cs @@ -1,6 +1,10 @@ +using System.ComponentModel.DataAnnotations; + namespace Microsoft.AI.DevTeam; public class QdrantOptions { + [Required] public string Endpoint { get; set; } + [Required] public int VectorSize { get; set; } } \ No newline at end of file diff --git a/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/ServiceOptions.cs b/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/ServiceOptions.cs index 244bd0977..33228424e 100644 --- a/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/ServiceOptions.cs +++ b/samples/gh-flow/src/Microsoft.AI.DevTeam/Options/ServiceOptions.cs @@ -1,5 +1,10 @@ +using System.ComponentModel.DataAnnotations; + namespace Microsoft.AI.DevTeam; public class ServiceOptions { + private string _ingesterUrl; + + [Required] public string IngesterUrl { get; set; } } \ No newline at end of file diff --git a/samples/gh-flow/src/Microsoft.AI.DevTeam/Program.cs b/samples/gh-flow/src/Microsoft.AI.DevTeam/Program.cs index 6c6841a94..636fd316d 100644 --- a/samples/gh-flow/src/Microsoft.AI.DevTeam/Program.cs +++ b/samples/gh-flow/src/Microsoft.AI.DevTeam/Program.cs @@ -12,6 +12,7 @@ using Microsoft.Extensions.Http.Resilience; using Microsoft.SemanticKernel.Memory; using Microsoft.SemanticKernel.Connectors.Qdrant; using Microsoft.SemanticKernel.Connectors.OpenAI; +using System.Configuration; var builder = WebApplication.CreateBuilder(args); builder.Services.AddSingleton(); @@ -41,34 +42,47 @@ builder.Services.AddApplicationInsightsTelemetry(); builder.Services.AddOptions() .Configure((settings, configuration) => { - configuration.GetSection("GithubOptions").Bind(settings); - }); + configuration.GetSection(nameof(GithubOptions)).Bind(settings); + }) + .ValidateDataAnnotations() + .ValidateOnStart(); + builder.Services.AddOptions() .Configure((settings, configuration) => { - configuration.GetSection("AzureOptions").Bind(settings); - }); + configuration.GetSection(nameof(AzureOptions)).Bind(settings); + }) + .ValidateDataAnnotations() + .ValidateOnStart(); + builder.Services.AddOptions() .Configure((settings, configuration) => { - configuration.GetSection("OpenAIOptions").Bind(settings); - }); + configuration.GetSection(nameof(OpenAIOptions)).Bind(settings); + }) + .ValidateDataAnnotations() + .ValidateOnStart(); + builder.Services.AddOptions() .Configure((settings, configuration) => { - configuration.GetSection("QdrantOptions").Bind(settings); - }); + configuration.GetSection(nameof(QdrantOptions)).Bind(settings); + }) + .ValidateDataAnnotations() + .ValidateOnStart(); + builder.Services.AddOptions() .Configure((settings, configuration) => { - configuration.GetSection("ServiceOptions").Bind(settings); - }); + configuration.GetSection(nameof(ServiceOptions)).Bind(settings); + }) + .ValidateDataAnnotations() + .ValidateOnStart(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); - builder.Host.UseOrleans(siloBuilder => { @@ -91,7 +105,7 @@ app.UseRouting() .UseEndpoints(endpoints => { var ghOptions = app.Services.GetService>().Value; - endpoints.MapGitHubWebhooks(secret: ghOptions.WebhookSecret ); + endpoints.MapGitHubWebhooks(secret: ghOptions.WebhookSecret); }); app.Map("/dashboard", x => x.UseOrleansDashboard()); @@ -125,11 +139,12 @@ static Kernel CreateKernel(IServiceProvider provider) clientOptions.Retry.NetworkTimeout = TimeSpan.FromMinutes(5); var openAIClient = new OpenAIClient(new Uri(openAiConfig.Endpoint), new AzureKeyCredential(openAiConfig.ApiKey), clientOptions); var builder = Kernel.CreateBuilder(); - builder.Services.AddLogging( c=> c.AddConsole().AddDebug().SetMinimumLevel(LogLevel.Debug)); + builder.Services.AddLogging(c => c.AddConsole().AddDebug().SetMinimumLevel(LogLevel.Debug)); builder.Services.AddAzureOpenAIChatCompletion(openAiConfig.DeploymentOrModelId, openAIClient); - builder.Services.ConfigureHttpClientDefaults(c=> + builder.Services.ConfigureHttpClientDefaults(c => { - c.AddStandardResilienceHandler().Configure( o=> { + c.AddStandardResilienceHandler().Configure(o => + { o.Retry.MaxRetryAttempts = 5; o.Retry.BackoffType = Polly.DelayBackoffType.Exponential; });