Replies: 1 comment 3 replies
-
I'm unclear what you're asking for specifically. There are many ways you can get data into an AIFunction invocation. You can associate data with the function at the time it's created, either via closure or via AdditionalProperties, which if you're creating your own you can populate however you want, or using AIFunctionFactory you can populate using AIFunctionFactoryOptions.AdditionalProperties. When invoking an AIFunction, you pass in AIFunctionArguments, which not only includes the dictionary of named arguments, it also includes an arbitrary If you want more fine-grained control over how parameters are bound, you can utilize the AIFunctionFactoryOptions.ConfigureParameterBinding, which puts you in control over how each parameter is populated. The MCP C# SDK, for example, uses that to automatically bind parameters from DI: If you use the AIFunctionFactory.Create overload that takes an instance MethodInfo and a createInstanceFunc, you can also run your own arbitrary logic when creating the target object the instance method will be called on, each time, and you can do whatever you want to configure that instance. Is there something more you're hoping for? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We are migrating from PydanticAI to MEAI and we are facing an issue when trying to get some context from a tool.
With PydanticAI you can do this
but I couldn't find an equivalent with MEAI.
The work-around was to create a UserContextAccessor à la IHttpContextAccessor.
Another work-around is to create the functions on the fly to capture the context in the closure but it's very inconvenient.
Is there a better way or would you consider adding a new API to do that?
Beta Was this translation helpful? Give feedback.
All reactions