Accessing agent data in AIFunctions
#1193
-
|
Semantic Kernel has That enables things like setting Is there something equivalent in MAF? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
|
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 dictionary, so you can create your wrapper function that augments the context passed into the "real" function with whatever additional state you want it to have access to. Do any of those help? |
Beta Was this translation helpful? Give feedback.
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…