Skip to content

MEAI docs: Function calling #6247

@SteveSandersonMS

Description

@SteveSandersonMS

An outcome from the TM review.

For function calling docs:

  • Emphasize that incoming args are untrusted data from the LLM
  • The exceptions are the parameter types special-cased by AIFunctionFactory:
    • CancellationToken is special and will receive a token that is chained onto the CT on the original call
    • AIFunctionArgument is special and describes all the incoming params as well as other context info (IServiceProvider)
    • IServiceProvider is special and will receive the SP provided when you set up the middleware chain originally
  • Beyond that, developers can also customize parameter binding with their own code using the AIFunctionFactoryOptions.ConfigureParameterBinding option. If they do that, it's up to them to know whether the data can be trusted or not based on how they have implemented the binding logic and where it gets its source data from.
  • Emphasize that in general, AIFunctions should be instance methods where possible. Then they can obtain trusted info about context from the instance they are a method on (e.g., to access the user's ClaimsPrincipal, other context about data being worked on, etc). This is always better than trying to round-trip information through the LLM, since anything that comes out of the LLM may be compromised.

Metadata

Metadata

Assignees

Labels

area-aiMicrosoft.Extensions.AI libraries

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions