You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Program.cs 2.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Microsoft.AutoGen.Agents.Worker.Client;
  2. using DevTeam;
  3. using Microsoft.AI.DevTeam;
  4. using DevTeam.Backend;
  5. using Octokit.Webhooks;
  6. using Microsoft.Extensions.Options;
  7. using DevTeam.Options;
  8. using Microsoft.Extensions.Azure;
  9. using Azure.Identity;
  10. using Octokit.Webhooks.AspNetCore;
  11. var builder = WebApplication.CreateBuilder(args);
  12. builder.AddServiceDefaults();
  13. builder.ConfigureSemanticKernel();
  14. builder.Services.AddHttpClient();
  15. builder.Services.AddControllers();
  16. builder.Services.AddSwaggerGen();
  17. builder.AddAgentWorker(builder.Configuration["AGENT_HOST"]!)
  18. .AddAgent<AzureGenie>(nameof(AzureGenie))
  19. //.AddAgent<Sandbox>(nameof(Sandbox))
  20. .AddAgent<Hubber>(nameof(Hubber));
  21. builder.Services.AddSingleton<AgentClient>();
  22. builder.Services.AddSingleton<WebhookEventProcessor, GithubWebHookProcessor>();
  23. builder.Services.AddSingleton<GithubAuthService>();
  24. builder.Services.AddSingleton<IManageAzure, AzureService>();
  25. builder.Services.AddSingleton<IManageGithub, GithubService>();
  26. builder.Services.AddTransient(s =>
  27. {
  28. var ghOptions = s.GetRequiredService<IOptions<GithubOptions>>();
  29. var logger = s.GetRequiredService<ILogger<GithubAuthService>>();
  30. var ghService = new GithubAuthService(ghOptions, logger);
  31. var client = ghService.GetGitHubClient();
  32. return client;
  33. });
  34. // TODO: Rework?
  35. builder.Services.AddOptions<GithubOptions>()
  36. .Configure<IConfiguration>((settings, configuration) =>
  37. {
  38. configuration.GetSection("Github").Bind(settings);
  39. })
  40. .ValidateDataAnnotations()
  41. .ValidateOnStart();
  42. builder.Services.AddAzureClients(clientBuilder =>
  43. {
  44. clientBuilder.AddArmClient(default);
  45. clientBuilder.UseCredential(new DefaultAzureCredential());
  46. });
  47. var app = builder.Build();
  48. app.MapDefaultEndpoints();
  49. app.UseRouting()
  50. .UseEndpoints(endpoints =>
  51. {
  52. var ghOptions = app.Services.GetRequiredService<IOptions<GithubOptions>>().Value;
  53. endpoints.MapGitHubWebhooks(secret: ghOptions.WebhookSecret);
  54. });;
  55. app.UseSwagger();
  56. app.UseSwaggerUI(c =>
  57. {
  58. c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
  59. });
  60. app.Run();