Skip to content

Conversation

@dkotter
Copy link
Collaborator

@dkotter dkotter commented Dec 4, 2025

What?

Partially closes #12

Adds the base Experiment and Ability code for Content Summarization. There will be a followup PR that adds in the UI to trigger summarization at the post level.

Why?

We want an Experiment that allows you to summarize content and then store that summary as post meta and optionally insert it as a block (both of those pending in the followup PR). To keep PRs as small as possible, this introduces the base framework for content summarization, both the Experiment and the Ability.

How?

  • Adds a new Summarization Experiment class and registers this as one of our default Experiments
  • Adds a new Summarization Ability that allows you to pass in either a post ID or stand-alone content and it will then generate a summary using the WP AI Client
  • Makes a minor adjustment to our get_post_context helper function to remove empty values
  • Adds in new tests to cover these changes

Testing Instructions

Since there isn't a UI for this yet, will need to make direct API requests to see this working.

Make an authenticated GET request to the main abilities endpoint and ensure the Summarization ability shows there

curl --location 'https://example.com/wp-json/wp-abilities/v1/abilities/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic ****'

Make an authenticated GET request to the Summarization endpoint and ensure information about the ability shows

curl --location 'https://example.com/wp-json/wp-abilities/v1/abilities/ai/summarization' \
--header 'Authorization: Basic ****'

Make an authenticated POST request to the Summarization run endpoint without passing valid data and ensure an error shows

curl --location 'https://example.com/wp-json/wp-abilities/v1/abilities/ai/summarization/run' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic ****' \
--data '{
    "input": {
    }
}'

Make an authenticated POST request to the Summarization run endpoint and pass in a post ID and ensure a summary is returned

curl --location 'https://example.com/wp-json/wp-abilities/v1/abilities/ai/summarization/run' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic ****' \
--data '{
    "input": {
        "post_id": 1
    }
}'

Make an authenticated POST request to the Summarization run endpoint and pass in a non valid post ID and ensure an error is returned

curl --location 'https://example.com/wp-json/wp-abilities/v1/abilities/ai/summarization/run' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic ****' \
--data '{
    "input": {
        "post_id": 999
    }
}'

Make an authenticated POST request to the Summarization run endpoint and pass in content and ensure a summary is returned

curl --location 'https://example.com/wp-json/wp-abilities/v1/abilities/ai/summarization/run' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic ****' \
--data '{
    "input": {
        "content": "Content entered here will be summarized"
    }
}'

Test using WordPress Playground

The changes in this pull request can be previewed and tested using this WordPress Playground instance:

Click here to test this pull request.

Open WordPress Playground Preview

@dkotter dkotter self-assigned this Dec 4, 2025
@github-actions
Copy link

github-actions bot commented Dec 4, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @prabinjha.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: prabinjha.

Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: JasonTheAdams <jason_the_adams@git.wordpress.org>
Co-authored-by: Ref34t <mokhaled@git.wordpress.org>
Co-authored-by: karmatosed <karmatosed@git.wordpress.org>
Co-authored-by: mathetos <webdevmattcrom@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 65.46763% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.75%. Comparing base (6478545) to head (00fdd9b).
⚠️ Report is 7 commits behind head on develop.

Files with missing lines Patch % Lines
includes/Abilities/Summarization/Summarization.php 66.03% 36 Missing ⚠️
...cludes/Experiments/Summarization/Summarization.php 46.66% 8 Missing ⚠️
...des/Abilities/Summarization/system-instruction.php 60.00% 4 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #136      +/-   ##
=============================================
+ Coverage      46.89%   48.75%   +1.86%     
- Complexity       208      235      +27     
=============================================
  Files             19       22       +3     
  Lines           1271     1403     +132     
=============================================
+ Hits             596      684      +88     
- Misses           675      719      +44     
Flag Coverage Δ
unit 48.75% <65.46%> (+1.86%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jeffpaul jeffpaul added this to the 0.2.0 milestone Dec 4, 2025
Copy link
Member

@JasonTheAdams JasonTheAdams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool, @dkotter! Left a few thoughts!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should clarify the data structure for the model to expect, and make it clear that the content is being summarized, while the context should be considered.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I've pulled the content out of the context now so those are more obviously separated: d186657

We'll also likely want to make this same change for the Title Generation Experiment but I can do that in a separate PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content Summarization

3 participants