mirror of
https://github.com/microsoft/autogen.git
synced 2025-10-18 19:39:58 +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;
|
namespace Microsoft.AI.DevTeam;
|
||||||
public class AzureOptions
|
public class AzureOptions
|
||||||
{
|
{
|
||||||
|
[Required]
|
||||||
public string SubscriptionId { get; set; }
|
public string SubscriptionId { get; set; }
|
||||||
|
[Required]
|
||||||
public string Location { get; set; }
|
public string Location { get; set; }
|
||||||
|
[Required]
|
||||||
public string ContainerInstancesResourceGroup { get; set; }
|
public string ContainerInstancesResourceGroup { get; set; }
|
||||||
|
[Required]
|
||||||
public string FilesShareName { get; set; }
|
public string FilesShareName { get; set; }
|
||||||
|
[Required]
|
||||||
public string FilesAccountName { get; set; }
|
public string FilesAccountName { get; set; }
|
||||||
|
[Required]
|
||||||
public string FilesAccountKey { get; set; }
|
public string FilesAccountKey { get; set; }
|
||||||
public string CosmosConnectionString { get; set; }
|
[Required]
|
||||||
public string SandboxImage { get; set; }
|
public string SandboxImage { get; set; }
|
||||||
public string ManagedIdentity { get; set; }
|
public string ManagedIdentity { get; set; }
|
||||||
|
public string CosmosConnectionString { get; set; }
|
||||||
}
|
}
|
@ -1,8 +1,14 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace Microsoft.AI.DevTeam;
|
namespace Microsoft.AI.DevTeam;
|
||||||
public class GithubOptions
|
public class GithubOptions
|
||||||
{
|
{
|
||||||
|
[Required]
|
||||||
public string AppKey { get; set; }
|
public string AppKey { get; set; }
|
||||||
|
[Required]
|
||||||
public int AppId { get; set; }
|
public int AppId { get; set; }
|
||||||
|
[Required]
|
||||||
public long InstallationId { get; set; }
|
public long InstallationId { get; set; }
|
||||||
|
[Required]
|
||||||
public string WebhookSecret { get; set; }
|
public string WebhookSecret { get; set; }
|
||||||
}
|
}
|
@ -1,10 +1,18 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace Microsoft.AI.DevTeam;
|
namespace Microsoft.AI.DevTeam;
|
||||||
public class OpenAIOptions
|
public class OpenAIOptions
|
||||||
{
|
{
|
||||||
|
[Required]
|
||||||
public string ServiceType { get; set; }
|
public string ServiceType { get; set; }
|
||||||
|
[Required]
|
||||||
public string ServiceId { get; set; }
|
public string ServiceId { get; set; }
|
||||||
|
[Required]
|
||||||
public string DeploymentOrModelId { get; set; }
|
public string DeploymentOrModelId { get; set; }
|
||||||
|
[Required]
|
||||||
public string EmbeddingDeploymentOrModelId { get; set; }
|
public string EmbeddingDeploymentOrModelId { get; set; }
|
||||||
|
[Required]
|
||||||
public string Endpoint { get; set; }
|
public string Endpoint { get; set; }
|
||||||
|
[Required]
|
||||||
public string ApiKey { get; set; }
|
public string ApiKey { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace Microsoft.AI.DevTeam;
|
namespace Microsoft.AI.DevTeam;
|
||||||
public class QdrantOptions
|
public class QdrantOptions
|
||||||
{
|
{
|
||||||
|
[Required]
|
||||||
public string Endpoint { get; set; }
|
public string Endpoint { get; set; }
|
||||||
|
[Required]
|
||||||
public int VectorSize { get; set; }
|
public int VectorSize { get; set; }
|
||||||
}
|
}
|
@ -1,5 +1,10 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace Microsoft.AI.DevTeam;
|
namespace Microsoft.AI.DevTeam;
|
||||||
public class ServiceOptions
|
public class ServiceOptions
|
||||||
{
|
{
|
||||||
|
private string _ingesterUrl;
|
||||||
|
|
||||||
|
[Required]
|
||||||
public string IngesterUrl { get; set; }
|
public string IngesterUrl { get; set; }
|
||||||
}
|
}
|
@ -12,6 +12,7 @@ using Microsoft.Extensions.Http.Resilience;
|
|||||||
using Microsoft.SemanticKernel.Memory;
|
using Microsoft.SemanticKernel.Memory;
|
||||||
using Microsoft.SemanticKernel.Connectors.Qdrant;
|
using Microsoft.SemanticKernel.Connectors.Qdrant;
|
||||||
using Microsoft.SemanticKernel.Connectors.OpenAI;
|
using Microsoft.SemanticKernel.Connectors.OpenAI;
|
||||||
|
using System.Configuration;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.Services.AddSingleton<WebhookEventProcessor, GithubWebHookProcessor>();
|
builder.Services.AddSingleton<WebhookEventProcessor, GithubWebHookProcessor>();
|
||||||
@ -41,34 +42,47 @@ builder.Services.AddApplicationInsightsTelemetry();
|
|||||||
builder.Services.AddOptions<GithubOptions>()
|
builder.Services.AddOptions<GithubOptions>()
|
||||||
.Configure<IConfiguration>((settings, configuration) =>
|
.Configure<IConfiguration>((settings, configuration) =>
|
||||||
{
|
{
|
||||||
configuration.GetSection("GithubOptions").Bind(settings);
|
configuration.GetSection(nameof(GithubOptions)).Bind(settings);
|
||||||
});
|
})
|
||||||
|
.ValidateDataAnnotations()
|
||||||
|
.ValidateOnStart();
|
||||||
|
|
||||||
builder.Services.AddOptions<AzureOptions>()
|
builder.Services.AddOptions<AzureOptions>()
|
||||||
.Configure<IConfiguration>((settings, configuration) =>
|
.Configure<IConfiguration>((settings, configuration) =>
|
||||||
{
|
{
|
||||||
configuration.GetSection("AzureOptions").Bind(settings);
|
configuration.GetSection(nameof(AzureOptions)).Bind(settings);
|
||||||
});
|
})
|
||||||
|
.ValidateDataAnnotations()
|
||||||
|
.ValidateOnStart();
|
||||||
|
|
||||||
builder.Services.AddOptions<OpenAIOptions>()
|
builder.Services.AddOptions<OpenAIOptions>()
|
||||||
.Configure<IConfiguration>((settings, configuration) =>
|
.Configure<IConfiguration>((settings, configuration) =>
|
||||||
{
|
{
|
||||||
configuration.GetSection("OpenAIOptions").Bind(settings);
|
configuration.GetSection(nameof(OpenAIOptions)).Bind(settings);
|
||||||
});
|
})
|
||||||
|
.ValidateDataAnnotations()
|
||||||
|
.ValidateOnStart();
|
||||||
|
|
||||||
builder.Services.AddOptions<QdrantOptions>()
|
builder.Services.AddOptions<QdrantOptions>()
|
||||||
.Configure<IConfiguration>((settings, configuration) =>
|
.Configure<IConfiguration>((settings, configuration) =>
|
||||||
{
|
{
|
||||||
configuration.GetSection("QdrantOptions").Bind(settings);
|
configuration.GetSection(nameof(QdrantOptions)).Bind(settings);
|
||||||
});
|
})
|
||||||
|
.ValidateDataAnnotations()
|
||||||
|
.ValidateOnStart();
|
||||||
|
|
||||||
builder.Services.AddOptions<ServiceOptions>()
|
builder.Services.AddOptions<ServiceOptions>()
|
||||||
.Configure<IConfiguration>((settings, configuration) =>
|
.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<IManageAzure, AzureService>();
|
||||||
builder.Services.AddSingleton<IManageGithub, GithubService>();
|
builder.Services.AddSingleton<IManageGithub, GithubService>();
|
||||||
builder.Services.AddSingleton<IAnalyzeCode, CodeAnalyzer>();
|
builder.Services.AddSingleton<IAnalyzeCode, CodeAnalyzer>();
|
||||||
|
|
||||||
|
|
||||||
builder.Host.UseOrleans(siloBuilder =>
|
builder.Host.UseOrleans(siloBuilder =>
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -91,7 +105,7 @@ app.UseRouting()
|
|||||||
.UseEndpoints(endpoints =>
|
.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
var ghOptions = app.Services.GetService<IOptions<GithubOptions>>().Value;
|
var ghOptions = app.Services.GetService<IOptions<GithubOptions>>().Value;
|
||||||
endpoints.MapGitHubWebhooks(secret: ghOptions.WebhookSecret );
|
endpoints.MapGitHubWebhooks(secret: ghOptions.WebhookSecret);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.Map("/dashboard", x => x.UseOrleansDashboard());
|
app.Map("/dashboard", x => x.UseOrleansDashboard());
|
||||||
@ -125,11 +139,12 @@ static Kernel CreateKernel(IServiceProvider provider)
|
|||||||
clientOptions.Retry.NetworkTimeout = TimeSpan.FromMinutes(5);
|
clientOptions.Retry.NetworkTimeout = TimeSpan.FromMinutes(5);
|
||||||
var openAIClient = new OpenAIClient(new Uri(openAiConfig.Endpoint), new AzureKeyCredential(openAiConfig.ApiKey), clientOptions);
|
var openAIClient = new OpenAIClient(new Uri(openAiConfig.Endpoint), new AzureKeyCredential(openAiConfig.ApiKey), clientOptions);
|
||||||
var builder = Kernel.CreateBuilder();
|
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.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.MaxRetryAttempts = 5;
|
||||||
o.Retry.BackoffType = Polly.DelayBackoffType.Exponential;
|
o.Retry.BackoffType = Polly.DelayBackoffType.Exponential;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user