mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
f42a3ee6b9
* non-streaming chat completion * support streaming * simplify frontend clients + nit * nit * use baseaddress * rm unnecessary * refactor * remove conversation id for chatcompletions agent client * nits
53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using AgentWebChat.Web;
|
|
using AgentWebChat.Web.Components;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add service defaults & Aspire client integrations.
|
|
builder.AddServiceDefaults();
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents();
|
|
|
|
builder.Services.AddOutputCache();
|
|
|
|
// This URL uses "https+http://" to indicate HTTPS is preferred over HTTP.
|
|
// Learn more about service discovery scheme resolution at https://aka.ms/dotnet/sdschemes.
|
|
Uri baseAddress = new("https+http://agenthost");
|
|
|
|
// for some reason does not resolve with `apiservice` url
|
|
Uri a2aAddress = new("http://localhost:5390/a2a");
|
|
|
|
builder.Services.AddHttpClient<AgentDiscoveryClient>(client => client.BaseAddress = baseAddress);
|
|
builder.Services.AddSingleton(sp => new A2AAgentClient(sp.GetRequiredService<ILogger<A2AAgentClient>>(), a2aAddress));
|
|
|
|
builder.Services.AddHttpClient<OpenAIResponsesAgentClient>(client => client.BaseAddress = baseAddress);
|
|
builder.Services.AddHttpClient<OpenAIChatCompletionsAgentClient>(client => client.BaseAddress = baseAddress);
|
|
|
|
var app = builder.Build();
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAntiforgery();
|
|
|
|
app.UseOutputCache();
|
|
|
|
app.MapStaticAssets();
|
|
|
|
app.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
app.MapDefaultEndpoints();
|
|
|
|
app.Run();
|