Skip to content

Commit

Permalink
local client by default
Browse files Browse the repository at this point in the history
  • Loading branch information
rysweet committed Oct 8, 2024
1 parent 08ee08f commit 8b12b77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dotnet/src/Microsoft.AutoGen.Agents.Client/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static class App
public static async Task<WebApplication> StartAsync<T>(string name) where T : AgentBase
{
var clientBuilder = WebApplication.CreateBuilder();
clientBuilder.AddLocalAgentWorker().AddAgent<T>(name);
clientBuilder.AddAgentWorker().AddAgent<T>(name);
var clientApp = clientBuilder.Build();
await clientApp.StartAsync().ConfigureAwait(false);
return clientApp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@ namespace Microsoft.AutoGen.Agents.Client;

public static class HostBuilderExtensions
{
public static AgentApplicationBuilder AddLocalAgentWorker(this IHostApplicationBuilder clientBuilder)
{
clientBuilder.Services.AddHostedService<AgentWorkerRuntime>();
clientBuilder.Services.AddSingleton<AgentClient>();
clientBuilder.AddAgentWorker("https://localhost:5001");
return new AgentApplicationBuilder(clientBuilder);
}
public static AgentApplicationBuilder AddAgentWorker(this IHostApplicationBuilder builder, string agentServiceAddress)
private const string _defaultAgentServiceAddress = "https://localhost:5001";
public static AgentApplicationBuilder AddAgentWorker(this IHostApplicationBuilder builder, string agentServiceAddress =_defaultAgentServiceAddress, bool local = false)
{
builder.Services.AddGrpcClient<AgentRpc.AgentRpcClient>(options =>
{
Expand Down Expand Up @@ -55,6 +49,7 @@ public static AgentApplicationBuilder AddAgentWorker(this IHostApplicationBuilde
});
});
builder.Services.TryAddSingleton(DistributedContextPropagator.Current);
builder.Services.AddSingleton<AgentClient>();
builder.Services.AddSingleton<AgentWorkerRuntime>();
builder.Services.AddSingleton<IHostedService>(sp => sp.GetRequiredService<AgentWorkerRuntime>());
builder.Services.AddKeyedSingleton("EventTypes", (sp, key) =>
Expand Down

0 comments on commit 8b12b77

Please sign in to comment.