Skip to content

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

@verdie-g

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

.NETagentsIssues related to single agentsv1.0Features being tracked for the version 1.0 GA

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions