Skip to content

[.NET] Support creating tools from Microsoft.Extensions.AI.AIFunctionFactory #4040

@LittleLittleCloud

Description

@LittleLittleCloud

What feature would you like to be added?

Create tools from Microsoft.Extensions.AI.AIFunctionFactory

[Description("...")]
public static async Task<string> UpperCase(string message)
{
    return message.ToUpper();
}

var tools = AIFunctionFactory.Create(UpperCase)
var middleware = new FunctionCallMiddleware([tools])
var agentWithTools = agent.RegisterMiddleware(middleware);

In the long run, we will want to replace FunctionContract and FunctionParameterContract with the contract classes from M.E.A.I, and maybe update source generator to generate those contract classes instead

Why is this needed?

This enables developers to create type-safe function call for autogen agents even where source generator is not available. E.G. dotnet interactive

cc @colombod

Metadata

Metadata

Labels

0.2Issues which are related to the pre 0.4 codebase

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions