Skip to content

.NET: [API Proposal] IHostedAgentBuilder.WithAITools with IServiceProvider #3063

Description

@verdie-g

When registering tools with WithAITool the DI container is not built yet so you can't use it. That's not great because tools usually have dependencies. This problem could be solved with a method like this

IHostedAgentBuilder WithAITools(this IHostedAgentBuilder builder, Func<IServiceProvider, IEnumerable<AITool>> factory);

used like this

builder.Services.AddAIAgent("my_agent", "")
    .WithAITools(sp =>
    {
        var userService = sp.GetRequiredService<UserService>();
        return [AIFunctionFactory.Create(userService.GetUser)];
    });

Metadata

Metadata

Labels

.NETUsage: [Issues, PRs], Target: .NetagentsUsage: [Issues, PRs], Target: Single agent

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions