Ryan Sweet 1edf5cfe9c
working on scaffolding a new dotnet intro sample for #531 (#536)
* interim stash

* interim stash

* interim checkpoint

* broken stash

* whoops

* merge sln files

* fix a bunch of refactoring errors

* moving more to core vs samples

* interim

* fixup the devteam sample

* fix ci

* fixup soln file

* trying to fix ci

* trying to fix ci

* adding back

* still trying

* recreate

* next step

* adding it back

* trying to fix

* Rename Autogen -> AutoGen (#567)

* Add transparency faqs (#566)

* remove Autogen

* add AutoGen back

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>

---------

Co-authored-by: Xiaoyun Zhang <xiaoyuz@microsoft.com>
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
2024-09-19 01:41:44 +00:00

72 lines
2.1 KiB
C#

using Microsoft.AutoGen.Agents.Worker.Client;
using Microsoft.AutoGen.Agents.Extensions.SemanticKernel;
using Microsoft.AI.DevTeam;
using DevTeam.Backend;
using Octokit.Webhooks;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Azure;
using Azure.Identity;
using Octokit.Webhooks.AspNetCore;
using DevTeam.Options;
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.ConfigureSemanticKernel();
builder.Services.AddHttpClient();
builder.Services.AddControllers();
builder.Services.AddSwaggerGen();
builder.AddAgentWorker(builder.Configuration["AGENT_HOST"]!)
.AddAgent<AzureGenie>(nameof(AzureGenie))
//.AddAgent<Sandbox>(nameof(Sandbox))
.AddAgent<Hubber>(nameof(Hubber));
builder.Services.AddSingleton<AgentClient>();
builder.Services.AddSingleton<WebhookEventProcessor, GithubWebHookProcessor>();
builder.Services.AddSingleton<GithubAuthService>();
builder.Services.AddSingleton<IManageAzure, AzureService>();
builder.Services.AddSingleton<IManageGithub, GithubService>();
builder.Services.AddTransient(s =>
{
var ghOptions = s.GetRequiredService<IOptions<GithubOptions>>();
var logger = s.GetRequiredService<ILogger<GithubAuthService>>();
var ghService = new GithubAuthService(ghOptions, logger);
var client = ghService.GetGitHubClient();
return client;
});
// TODO: Rework?
builder.Services.AddOptions<GithubOptions>()
.Configure<IConfiguration>((settings, configuration) =>
{
configuration.GetSection("Github").Bind(settings);
})
.ValidateDataAnnotations()
.ValidateOnStart();
builder.Services.AddAzureClients(clientBuilder =>
{
clientBuilder.AddArmClient(default);
clientBuilder.UseCredential(new DefaultAzureCredential());
});
var app = builder.Build();
app.MapDefaultEndpoints();
app.UseRouting()
.UseEndpoints(endpoints =>
{
var ghOptions = app.Services.GetRequiredService<IOptions<GithubOptions>>().Value;
endpoints.MapGitHubWebhooks(secret: ghOptions.WebhookSecret);
});;
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
app.Run();