mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
45 lines
1.7 KiB
C#
45 lines
1.7 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using AGUIDojoServer;
|
|
using Microsoft.AspNetCore.HttpLogging;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddHttpLogging(logging =>
|
|
{
|
|
logging.LoggingFields = HttpLoggingFields.RequestPropertiesAndHeaders | HttpLoggingFields.RequestBody
|
|
| HttpLoggingFields.ResponsePropertiesAndHeaders | HttpLoggingFields.ResponseBody;
|
|
logging.RequestBodyLogLimit = int.MaxValue;
|
|
logging.ResponseBodyLogLimit = int.MaxValue;
|
|
});
|
|
|
|
builder.Services.AddHttpClient().AddLogging();
|
|
builder.Services.ConfigureHttpJsonOptions(options => options.SerializerOptions.TypeInfoResolverChain.Add(AGUIDojoServerSerializerContext.Default));
|
|
builder.Services.AddAGUI();
|
|
|
|
WebApplication app = builder.Build();
|
|
|
|
app.UseHttpLogging();
|
|
|
|
// Initialize the factory
|
|
ChatClientAgentFactory.Initialize(app.Configuration);
|
|
|
|
// Map the AG-UI agent endpoints for different scenarios
|
|
app.MapAGUI(ChatClientAgentFactory.CreateAgenticChat(), "/agentic_chat");
|
|
|
|
app.MapAGUI(ChatClientAgentFactory.CreateBackendToolRendering(), "/backend_tool_rendering");
|
|
|
|
app.MapAGUI(ChatClientAgentFactory.CreateHumanInTheLoop(), "/human_in_the_loop");
|
|
|
|
app.MapAGUI(ChatClientAgentFactory.CreateToolBasedGenerativeUI(), "/tool_based_generative_ui");
|
|
|
|
app.MapAGUI(ChatClientAgentFactory.CreateAgenticUI(), "/agentic_generative_ui");
|
|
|
|
var jsonOptions = app.Services.GetRequiredService<IOptions<Microsoft.AspNetCore.Http.Json.JsonOptions>>();
|
|
app.MapAGUI(ChatClientAgentFactory.CreateSharedState(jsonOptions.Value.SerializerOptions), "/shared_state");
|
|
|
|
await app.RunAsync();
|
|
|
|
public partial class Program;
|