Skip to content

Conversation

@dkotter
Copy link
Collaborator

@dkotter dkotter commented Nov 3, 2025

Important

This PR is branched off of #61. That PR should be merged before
this PR is reviewed. Once merged, I can rebase this PR so the same
code doesn't have to be reviewed again.

What?

Partially closes #10

Builds off of the Title Generation feature base work done in #61 to wire up the actual execution of title generation.

Why?

In PR #61, we introduced the Title Generation Ability and Feature classes but the actual generation of titles wasn't completed there. This PR finishes that piece, though note there still isn't any UI to trigger this functionality, it all needs to be done via direct API requests.

How?

  • Pulls in the add/api-credentials-management branch of the WP AI Client repo (instead of trunk) to take advantage of the new settings screen introduced there. Once that is merged and released, this can be changed to pull from an actual release instead
  • Ensures this new settings page is registered properly
  • Adds in a new API_Request class that will be used to make requests to an AI Provider, using the PHP AI Client
  • Adds a generate_titles method to the Title Generation Feature and uses that in the execute callback of the Title Generation Ability
  • Adds a new param at the Feature level to see the system instruction we want to use when making requests to an LLM

Testing Instructions

There is no UI yet but can be tested by making direct API requests to the Title Generation Ability run endpoint. First you'll need to login to WordPress and go to Settings > AI Credentials and add in at least one API key.

Make an authenticated POST request to the Title Generation run endpoint and ensure a title is generated based on the content you provide

curl --location 'https://example.com/wp-json/wp-abilities/v1/abilities/ai/title-generation/run' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic ****' \
--data '{
    "input": {
        "content": "this is some content!",
    }
}'

Make an authenticated POST request to the Title Generation run endpoint, passing in a valid post ID, and ensure a title is generated

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

Make an authenticated POST request to the Title Generation run endpoint, passing in a valid post ID and number and ensure multiple titles are generated

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

Make an authenticated POST request to the Title Generation run endpoint and don't pass any content or post ID and ensure an error is returned

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

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.

… an ability. Make a few updates to our base REST endpoint
…ty for the title generation ability into the new ability class
…st we will use the content from that. And a number from 1 to 10 to control how many titles we generate
… easily set credentials. Initialize the settings screen
@dkotter dkotter added this to the 0.1.0 milestone Nov 3, 2025
@dkotter dkotter self-assigned this Nov 3, 2025
@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

❌ Patch coverage is 78.24427% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.43%. Comparing base (e76b0b2) to head (70677b9).
⚠️ Report is 8 commits behind head on trunk.

Files with missing lines Patch % Lines
...des/Features/Title_Generation/Title_Generation.php 42.50% 23 Missing ⚠️
includes/API_Request.php 78.68% 13 Missing ⚠️
includes/bootstrap.php 0.00% 11 Missing ⚠️
includes/Abstracts/Abstract_Feature.php 76.92% 6 Missing ⚠️
includes/Abilities/Title_Generation.php 95.83% 4 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##              trunk      #67       +/-   ##
=============================================
+ Coverage     48.48%   65.43%   +16.94%     
- Complexity       45      115       +70     
=============================================
  Files             6       11        +5     
  Lines           198      460      +262     
=============================================
+ Hits             96      301      +205     
- Misses          102      159       +57     
Flag Coverage Δ
unit 65.43% <78.24%> (+16.94%) ⬆️

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.

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.

Title Generation / Rewriting

1 participant