Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a prerequisite for another change I'm working on, which is updating to the latest Microsoft.Extensions.AI libraries.
One of the changes in M.E.AI is that
AIFunction
no longer exposes parameter metadata. This means the existing implementation ofIStructuredPredictor
in theCorrectiveRetrievalAugmentedGeneration
example needs to be changed, since that depended on setting parameter metadata.I could have done this by manually stitching together different bits of JSON schema so that most of the existing implementation would continue to work. However, I think there's a simpler way that's more future-proof, which is not to use
IStructuredPredictor
and instead to use M.E.AI's structured output mechanism along with a type that represents the possible outputs, i.e.:By asking the LLM for an instance of
PlanEvaluationResult
, we achieve the same effect: getting it to return either aPlan
or aPlanResult
. This isn't enforced at the level of JSON schema, but rather works through prompting. The description here instructs the LLM to populate only one of the two properties, which it will do reliably enough.@colombod I hope you're OK with this change. I have to change the implementation one way or another so that I can update to the latest M.E.AI. The change I've made here is hopefully well enough aligned with your intention that it won't change the meaning of the exercise overall.