Skip to content

Explore having the LLM return content in JSON schema instead of WordPress block markup#1119

Open
dkotter wants to merge 10 commits into
developfrom
update/block-renderer
Open

Explore having the LLM return content in JSON schema instead of WordPress block markup#1119
dkotter wants to merge 10 commits into
developfrom
update/block-renderer

Conversation

@dkotter

@dkotter dkotter commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

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-core package (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

  1. Checkout this branch and run npm i && npm run build
  2. Turn on the Content Generation Feature and configure it correctly
  3. Create a new post and then click on the sparkle icon in the lower right corner of the editor
  4. In the box that opens up, add your article summary you want to generate (i.e. brief history of WordPress)
  5. Send that request off and ensure you see valid results rendered
  6. Ensure you can insert that content into the editor and it renders properly there

Changelog Entry

Changed - For our Content Generation Feature, have the LLM return JSON data instead of block markup and then parse that out ourselves

Credits

Props @fabiankaegy, @dkotter

Checklist:

Open WordPress Playground Preview

@dkotter dkotter added this to the Future Release milestone Jun 16, 2026
@dkotter dkotter self-assigned this Jun 16, 2026
@dkotter dkotter requested review from a team and jeffpaul as code owners June 16, 2026 19:43
@github-actions github-actions Bot added the needs:code-review This requires code review. label Jun 16, 2026
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@github-actions github-actions Bot added the needs:refresh This requires a refreshed PR to resolve. label Jun 18, 2026
@github-actions github-actions Bot removed the needs:refresh This requires a refreshed PR to resolve. label Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:code-review This requires code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant