mirror of
				https://github.com/microsoft/autogen.git
				synced 2025-10-31 17:59:50 +00:00 
			
		
		
		
	 a19c848622
			
		
	
	
		a19c848622
		
			
		
	
	
	
	
		
			
			* move optional base agents to separate package * rename main sdk to Core * reduce dependency graph Co-authored-by: @rysweet Authored-by: @kostapetan Co-authored-by: @kopetan-ms
		
			
				
	
	
		
			76 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			76 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| // Copyright (c) Microsoft Corporation. All rights reserved.
 | |
| // Program.cs
 | |
| 
 | |
| using Azure.Identity;
 | |
| using DevTeam.Backend;
 | |
| using DevTeam.Options;
 | |
| using Microsoft.AI.DevTeam;
 | |
| using Microsoft.AutoGen.Core;
 | |
| using Microsoft.AutoGen.Extensions.SemanticKernel;
 | |
| using Microsoft.Extensions.Azure;
 | |
| using Microsoft.Extensions.Options;
 | |
| using Octokit.Webhooks;
 | |
| using Octokit.Webhooks.AspNetCore;
 | |
| 
 | |
| 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<AgentWorker>();
 | |
| 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();
 |