-
Notifications
You must be signed in to change notification settings - Fork 33
Add the Featured Image Generation UI #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…hat as a dependency
… closely to render the image and set/remove buttons
…thing to use across loads
…en the component loads
… and add that as meta to the image
… an AI label below the image and only show that if the featured image has the AI meta set
…the text in that case
…text using the post ID. Then take that context and generate an image prompt. Finally pass that prompt into our image generation function. Also modify our system instructions a bit
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @prabinjha, @kurtrank. 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. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #146 +/- ##
==============================================
+ Coverage 46.89% 59.45% +12.56%
- Complexity 208 219 +11
==============================================
Files 19 20 +1
Lines 1271 1391 +120
==============================================
+ Hits 596 827 +231
+ Misses 675 564 -111
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
JasonTheAdams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One straightforward suggestion, but I'm also humming pretty hard at the flow of providing an AI prompt writing Ability in order to run the subsequent prompt. What problem is this extra roundtrip solving that we couldn't accomplish by compiling a prompt ourselves based on the post data? It feels like we could make due without this.
The only place I could see an Ability like that being genuinely useful is if a user had an input to do something like describe a picture, and we added a "Improve prompt" button. But even that would require more specific instructions based on the context. This feels too generic.
| // Increase the default timeout as image generation can take a while. | ||
| add_filter( | ||
| 'wp_ai_client_default_request_timeout', | ||
| static function () { | ||
| return 90; | ||
| } | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fortunately, there's a much better way of doing this on a per prompt basis! The builder has a using_request_options() method. So for this you'd add:
$request_options = new WordPress\AiClient\Providers\Http\DTO\RequestOptions();
$request_options->setTimeout(90);
$prompt->using_request_options($request_options);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's good to know, thanks for pointing that out. Updated in 460f529
|
@dkotter perhaps a docs page for this experiment like done in https://github.com/WordPress/ai/pull/155/changes#diff-f70665388390657902e73741dea03efcdadc4bd0ceb4432959f8903ae015c042? |
@JasonTheAdams I struggled coming up with an approach to turn an entire article into a useful image generation prompt (useful being key there), thus relying on AI to help us out here. I initially tried sending the entire article with a prompt along the lines of I did go back and forth on if this should be an Ability (the "generate a prompt from this context" piece) so happy to change that to be more specific to this use case instead of a globally exposed Ability if that helps at all. |
@jeffpaul I know James has mentioned these PRs are more WIP at the moment so wondering if that's the best example to copy from? I know our default Experiment did add a |
What?
Partially closes #13. This only handles generating featured images, I'm assuming we'll want image generation in other places as well (though could be tracked in new Issues if we want).
Adds in the UI to trigger Featured Image Generation
Why?
This builds on top of the work done in #134, which added Abilities that could be used to generate an image and/or import an image. This PR adds in the actual UI that triggers those Abilities in the Featured Image section of the edit post screen.
How?
Generate featured imagebutton that shows above the standardSet featured imagebuttonget-post-detailsAbility. Then pass those details to the newgenerate-promptAbility, along with our base purpose. Take the prompt this generates and pass it to our existingimage-generationAbility. Finally take the base64-encoded image it returns and pass it to our existingimage-importAbility to import the image into the Media LibraryGenerate featured imagetoGenerate new featured imageTesting Instructions
Settings > AI CredentialsSettings > AI ExperimentsGenerate featured imagebuttonThere is also one new Ability introduced in this PR that can be used to generate prompts. This will be tested as part of the above testing instructions but you can also test this Ability directly by making API requests, like the following:
Screenshots or screencast
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.