Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

eiriktsarpalis
Copy link
Member

@eiriktsarpalis eiriktsarpalis commented Feb 14, 2025

I tend to regard AIFunctionFactory to be more foundational infrastructure and less an extension that is typical of components found in the Microsoft.Extensions.AI project. This PR proposes we move it to the Abstractions so that:

  1. We remove a hard dependency on STJ 9 for function factories.
  2. Leaf client implementations can rely on that infrastructure to create canonical AIFunction instances of their own.

In additional to moving over the relevant source files, this PR is also renaming AIFunctionFactoryCreateOptions to AIFunctionFactoryOptions since the "Create" verb seemed redundant.

Microsoft Reviewers: Open in CodeFlow

@stephentoub
Copy link
Member

stephentoub commented Feb 14, 2025

Leaf client implementations can rely on that infrastructure to create canonical AIFunction instances of their own.

I've not seen any need for that. Have you?

We remove a hard dependency on STJ 9 for function factories.

I've also not seen that as a problem for apps, which are the general consumer of this.

This PR proposes we move it to the Abstractions so that:

My main concerns are:

  1. These aren't abstractions nor are they needed by the 90% case of implementors. They're typically an app level concern, and apps reference M.E.AI. If you need AIFunctionFactory, there's a super high chance you also need FunctionInvokingChatClient.
  2. This is just one creation method. What happens if we decide to add an OpenAPI import method, or for model context protocol, or bringing a prompt file in as a function, or other such imports. Those would naturally belong here as well, but also not in abstractions.
  3. We don't currently imbue the generated functions with metrics or other forms of telemetry, but we might want to (SK does). This would either prevent that or force more dependencies into abstractions.
  4. At some point I expect we'll add a source generator, and the type as is will get much less use.

Doesn't seem like the risk is worth the reward. And nothing prevents us from type forwarding them down later if we decide then we actually want this.

@jeffhandley jeffhandley added the area-ai Microsoft.Extensions.AI libraries label Mar 7, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Apr 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-ai Microsoft.Extensions.AI libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants