Microsoft.Extensions.AI.AIFunctionMetadata should allow to be initialized with a json schema string #5655
Labels
area-AI
enhancement
This issue represents an ask for new feature or an enhancement to an existing one
Description
I built a C# code generator to implement the boilerplate for Tools/Agents/Functions.
I already generate at compile time the json schema string complying to the OpenAI specification for any agent.
The AIFunctionMetadata should provide a way to be initialized with the json schema directly.
Currently I can only specify (but there is no example, therefore I don't know how) the schema in
AIFunctionReturnParameterMetadata
andAIFunctionParameterMetadata
.Anyway, the problem with
AIFunctionParameterMetadata
is that the json section specifying whether the parameter is required or not, belongs to the parent key (properties
). This means that even if I can initialize this class with each parameter schema, I cannot specify therequired
field.To get rid of all the problems and completely avoid the serialization at runtime, the root class AIFunctionMetadata should allow to take the entire schema. This also provides better performance.
Reproduction Steps
Expected behavior
I expect:
AIFunctionMetadata
with the entire schema, as for the OpenAI specification.Actual behavior
See example above: the ability to specify the schema per-parameter is not sufficient and does not provide any benefit
Regression?
No
Known Workarounds
Use reflection and serialize at runtime
Configuration
.NET 9.0.100
Other information
No response
The text was updated successfully, but these errors were encountered: