Prompt template extension points#770
Conversation
|
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 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. |
…emplate-extension-points
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #770 +/- ##
=============================================
+ Coverage 76.41% 76.51% +0.09%
- Complexity 1828 1829 +1
=============================================
Files 87 87
Lines 7764 7792 +28
=============================================
+ Hits 5933 5962 +29
+ Misses 1831 1830 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add prompt template extension points
Summary
Introduces consistent, scoped extension points so developers can customize the prompts
and model configuration of AI abilities without forking the plugin. Adds three
per-ability filter hooks plus a developer guide.
Closes #192
What changed
A single slug helper on
Abstract_Abilityderives a hook-safe slug from each abilityname (
ai/title-generation→title_generation), and three filters are wired throughevery AI ability:
wpai_{slug}_system_instruction— override/extend the system instruction for oneability. Added once in
Abstract_Ability::get_system_instruction(), running afterthe existing global
wpai_system_instructionfilter.wpai_{slug}_prompt— modify the assembled user prompt before it is sent. Added tothe 10 abilities that did not already expose one.
wpai_{slug}_prompt_builder— adjust temperature, model/provider preference, requestoptions, etc. Added to all 12 prompt-building abilities, after the default model
preference is applied and before generation support is verified.
Abilities covered: Title, Excerpt, Summarization, Content Resizing, Meta Description,
Editorial Updates, Editorial Notes, Alt Text, Image Prompt Generation, Image Generation,
Comment Analysis, Content Classification.
Where abilities carry extra context, it is passed as additional filter arguments
(e.g.
$lengthfor summarization,$block_typefor editorial notes,$actionfor contentresizing).
Backward compatibility
wpai_system_instructionfilter is unchanged; the new scoped filter runs after it.meta_descriptionandcontent_classificationalready shipped awpai_{slug}_promptfilter with richer signatures (
$content/$title, taxonomy args). Those are left exactlyas-is — no duplicate hook is registered — so existing integrations keep working. They are
documented alongside the new hooks.
wpai_meta_description_result_temperaturestill applies; the new meta-description builderfilter runs after it.
byte-for-byte unchanged.
Design notes / decisions
A few decisions were made in the absence of issue feedback (happy to adjust):
instruction control; the global filter alone would require name-branching.
_promptis the image prompt (not postcontent), and editorial guidelines are appended after the filter — documented as such.
set_provider_model_preference()so it can intentionallyoverride the developer-mode model choice without breaking the default path.
comment_analysis,content_classification,editorial_notes) document that the builder should be extended, not replaced, to preserveJSON response schemas.