-
Notifications
You must be signed in to change notification settings - Fork 43
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 50.33% 59.50% +9.17%
- Complexity 366 397 +31
=============================================
Files 26 29 +3
Lines 1951 2136 +185
=============================================
+ Hits 982 1271 +289
+ Misses 969 865 -104
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 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 |
|
I chatted with some other folks and did some research on this, @dkotter, and you're right. In fact, it's rather complex. 😅 Image prompts are strange things and they vary depending on whether the image generation model is using diffusion or a transformer. If diffusion, things like context and history are more more confusing, as those models tend to expect the prompt to be rather focused on describing the image. Transformer models are more forgiving, but still work better when the prompt focuses on the image. In this case we're really describing two bits of work for the models:
Trying to get the image generation model to do both is, as you found, not particularly successful. In fact, depending on what type of model you used it could be really bad. Hahah! So it does make sense to have a model and system prompt focused on taking content and deriving an image prompt. It will need to understand that the content is a source of inspiration and to look for things like archetypes and what not within the content. This is some prompt engineering in and of itself. We may even take more parameters for things like describing the style of the image and such, which the content itself won't provide. This gets into the territory of a content guidelines as James has explored. At this point I'm thinking it would be useful to have an "Image prompt from content" ability that takes in:
This way we can really focus the system prompt on understanding its singular purpose, which I think will improve the resulting image prompt. We may consider having default style instructions so the generated images are somewhat consistent. |
Given that we'll likely have the same problem should we get into video generation, should we be more generic in naming this ability than tying it directly to "image"? |
I don't think so. I believe video prompts will want their own tuning and such. I think we should stick to just images for now and tackle videos later. |
…ic Ability for image generation
…lity with the proper methods to generate a prompt
…keep the amount of content we send to a minimum
@JasonTheAdams Okay, I've updated this PR to take all the above into consideration. There is now a more specific Ability, This Ability will then generate an image generation prompt which we then pass directly to an image generation model. In my testing this is all working as expected but definitely open to suggestions on the system instructions we're using here and any other default instructions we may want in place to guide things. |
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 as well as a new Ability to generate an image generation prompt.
How?
Generate featured imagebutton that shows above the standardSet featured imagebuttonget-post-detailsAbility. Then pass those details to the newimage-prompt-generationAbility, along with our content and context. 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 imagebuttonTo directly test the new generate image prompt Ability, can make an 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.