-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add WP-CLI
command to bulk process excerpts
#516
Conversation
…hat already have an excerpt set.
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.
Thanks for adding this @dkotter. This looks great and works well. I haven't tested with large dataset but looks great. 🚀
Added some nice to have notes, but not necessary to fix to merge this
Thanks.
…ge instead of a logged message but don't stop execution
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.
Description of the Change
In #405 we added the ability to manually generate excerpts on individual items. This is a follow up that adds a
WP-CLI
command that can be used to process items in bulk, adding generated excerpts to those items.One thing to note is that OpenAI has rate limits on their APIs, so you may run into that if processing too many items at a time. For instance, free accounts only get 3 requests per minute on the ChatGPT API, so very easy to hit that. Paid accounts go up to 3500 requests per minute, so unlikely to run into issues. We may want to explore adding rate limiting into ClassifAI at some point to ensure these limits aren't hit.
The new command looks like:
and has the following options:
post_type
argument that will be used if no post IDs are passed inpost_status
argument that will be used along with thepost_type
argument. Defaults topublish
per_page
argument. This controls how many items we process in each batch. Defaults to 100. As an example, if you have 1000 items to process, all of these will be processed but will be done in batches of 100 for performance reasonsforce
argument that defaults tofalse
. Will only process items that don't have an excerpt set if set tofalse
dry-run
argument that defaults totrue
. You must passfalse
to actually run the commandHere are some example commands that can be run:
Closes #416
How to test the Change
Try running some of the
WP-CLI
commands as described above and ensure they all work as expectedChangelog Entry
Credits
Props @dkotter
Checklist: