Skip to content
Discussion options

You must be logged in to vote

AIFunctions have access to the IServiceProvider, so you can provide transient or scoped state into any AIFunction via that.

AIFunctions also have access to FunctionInvokingChatClient.CurrentContext, which provides access to whatever ChatOptions were provided to the operation. Those ChatOptions have an AdditionalProperties dictionary, so you can flow arbitrary state from the caller through to any/all function invocation.

You can also wrap AIFunctions in delegating functions and provide those wrappers as the tools instead. That means for each RunAsync call, you can customize state provided into the functions. AIFunction.InvokeAsync accepts an AIFunctionArguments that has on it a Context dic…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@stephentoub
Comment options

@jooooel
Comment options

@itayfisz
Comment options

@stephentoub
Comment options

@nor0x
Comment options

Answer selected by jooooel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants