mirror of
https://github.com/microsoft/autogen.git
synced 2025-10-17 02:49:30 +00:00
[gh-flow] Fail to start if settings are missing (#43)
This commit is contained in:
parent
1ede63f9a8
commit
b08b696145
@ -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; }
|
||||
}
|
@ -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; }
|
||||
}
|
@ -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; }
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
@ -1,5 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Microsoft.AI.DevTeam;
|
||||
public class ServiceOptions
|
||||
{
|
||||
private string _ingesterUrl;
|
||||
|
||||
[Required]
|
||||
public string IngesterUrl { get; set; }
|
||||
}
|
@ -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<WebhookEventProcessor, GithubWebHookProcessor>();
|
||||
@ -41,34 +42,47 @@ builder.Services.AddApplicationInsightsTelemetry();
|
||||
builder.Services.AddOptions<GithubOptions>()
|
||||
.Configure<IConfiguration>((settings, configuration) =>
|
||||
{
|
||||
configuration.GetSection("GithubOptions").Bind(settings);
|
||||
});
|
||||
configuration.GetSection(nameof(GithubOptions)).Bind(settings);
|
||||
})
|
||||
.ValidateDataAnnotations()
|
||||
.ValidateOnStart();
|
||||
|
||||
builder.Services.AddOptions<AzureOptions>()
|
||||
.Configure<IConfiguration>((settings, configuration) =>
|
||||
{
|
||||
configuration.GetSection("AzureOptions").Bind(settings);
|
||||
});
|
||||
configuration.GetSection(nameof(AzureOptions)).Bind(settings);
|
||||
})
|
||||
.ValidateDataAnnotations()
|
||||
.ValidateOnStart();
|
||||
|
||||
builder.Services.AddOptions<OpenAIOptions>()
|
||||
.Configure<IConfiguration>((settings, configuration) =>
|
||||
{
|
||||
configuration.GetSection("OpenAIOptions").Bind(settings);
|
||||
});
|
||||
configuration.GetSection(nameof(OpenAIOptions)).Bind(settings);
|
||||
})
|
||||
.ValidateDataAnnotations()
|
||||
.ValidateOnStart();
|
||||
|
||||
builder.Services.AddOptions<QdrantOptions>()
|
||||
.Configure<IConfiguration>((settings, configuration) =>
|
||||
{
|
||||
configuration.GetSection("QdrantOptions").Bind(settings);
|
||||
});
|
||||
configuration.GetSection(nameof(QdrantOptions)).Bind(settings);
|
||||
})
|
||||
.ValidateDataAnnotations()
|
||||
.ValidateOnStart();
|
||||
|
||||
builder.Services.AddOptions<ServiceOptions>()
|
||||
.Configure<IConfiguration>((settings, configuration) =>
|
||||
{
|
||||
configuration.GetSection("ServiceOptions").Bind(settings);
|
||||
});
|
||||
configuration.GetSection(nameof(ServiceOptions)).Bind(settings);
|
||||
})
|
||||
.ValidateDataAnnotations()
|
||||
.ValidateOnStart();
|
||||
|
||||
builder.Services.AddSingleton<IManageAzure, AzureService>();
|
||||
builder.Services.AddSingleton<IManageGithub, GithubService>();
|
||||
builder.Services.AddSingleton<IAnalyzeCode, CodeAnalyzer>();
|
||||
|
||||
|
||||
builder.Host.UseOrleans(siloBuilder =>
|
||||
{
|
||||
|
||||
@ -91,7 +105,7 @@ app.UseRouting()
|
||||
.UseEndpoints(endpoints =>
|
||||
{
|
||||
var ghOptions = app.Services.GetService<IOptions<GithubOptions>>().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;
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user