Explore having the LLM return content in JSON schema instead of WordPress block markup#1119
Open
dkotter wants to merge 10 commits into
Open
Explore having the LLM return content in JSON schema instead of WordPress block markup#1119dkotter wants to merge 10 commits into
dkotter wants to merge 10 commits into
Conversation
…n JSON. Modify our Providers to request JSON returned responses
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of the Change
For the Content Generation Feature, we specify in our prompt that the content returned should follow the WordPress block markup (with some examples). This seems to work but is fairly fragile as it relies on the LLM knowing what this block markup should look like.
There's a few alternatives to that approach and this PR is exploring one of those: having the LLM return content formatted as JSON and then having us parse that into valid block markup. In theory this should be more reliable and does open up a path where we could support a wider-range of block types (for example, blocks specific to a site or that come from a plugin that some sites may be using).
Some of the work here comes from the
@10up/block-renderer-corepackage (I was wanting to use the full suite but ran into issues getting that working in the block editor cc / @fabiankaegy). Our prompt is still static so won't include custom blocks but we now ask for things formatted as JSON and then parse that on the client-side to create our blocks.How to test the Change
npm i && npm run buildChangelog Entry
Credits
Props @fabiankaegy, @dkotter
Checklist: