Repository navigation
Deprecate the AI_Service layer - #905
Conversation
AI_Service was introduced in WordPress#101 (0.2.1) as a proposed centralized layer for AI provider access. It was never adopted by any experiment or ability, and a follow-up PR (WordPress#898) to wire it in was closed as not wanted. Removing the dead code rather than carrying it forward. Refs WordPress#233
Companion removal to the AI_Service class deletion. No other test depends on this file. Refs WordPress#233
Drops the get_ai_service() function and its AI_Service use-import. No longer needed now that AI_Service itself is gone; experiments and abilities call wp_ai_client_prompt() directly. Refs WordPress#233
The Services/ folder description referenced AI_Service; updated to reflect that it now only contains Guidelines. Refs WordPress#233
Drops the includes/Services/AI_Service.php entry from the Related Files list since the file no longer exists. Refs WordPress#233
Documents the removal under Unreleased. The historical 0.2.1 entry describing AI_Service's original introduction is left untouched. Refs WordPress#233
|
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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #905 +/- ##
==========================================
Coverage 80.41% 80.42%
- Complexity 2565 2566 +1
==========================================
Files 110 110
Lines 10437 10440 +3
==========================================
+ Hits 8393 8396 +3
Misses 2044 2044
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:
|
dkotter
left a comment
There was a problem hiding this comment.
@theaminulai Thanks for the PR! In thinking about it a bit more, since the class is public and the helper function is also public, better to deprecate those and remove later than just remove entirely. Otherwise anyone that is relying on those will hit fatal errors.
I've pushed changes to handle that deprecation process but let me know if all of that looks good to you. In addition, would be great to get the PR title and description updated since we're not removing anything in this release, just deprecating
|
@theaminulai checking in to see if you're able to make those changes that Darin referenced above? |
Mark AI_Service class and get_ai_service() helper as deprecated in the CHANGELOG. These were introduced in 0.2.1 but are not used anywhere in the plugin, as experiments and abilities call wp_ai_client_prompt() directly. Both will be removed in the next major release (ref: WordPress#233).
|
Thanks for the nudge, @jeffpaul — and thanks for pushing those changes, @dkotter. Deprecating rather than removing outright makes sense given both are public. I've reviewed the deprecation approach and it looks good to me — One thing I noticed was missing: no changelog entry for the deprecation. Just pushed one under Ready for another look whenever you get a chance. |
We don't add changelog entries to that file on an individual PR basis; those should be added to the PR description and we pull those out when generating a release. I've updated the PR description with that changelog and pushed a commit to remove that from the file |
What?
See #233
Deprecates the
AI_Serviceclass (includes/Services/AI_Service.php) and theget_ai_service()helper, rather than removing them outright.Why?
This started as an outright removal, since
AI_Service(introduced in #101 / 0.2.1) isn't used anywhere in the plugin and a follow-up attempt to adopt it (#898) was closed as not wanted. @dkotter pointed out that both the class and the helper are public — third-party code could be relying on them — so removing them immediately would cause fatal errors for anyone using them. Deprecating first and removing in the next major release is the safer path, consistent with how this plugin already deprecates hooks inincludes/Deprecated.php.How?
AI_Service::__construct()now calls_deprecated_class( self::class, 'x.x.x', 'wp_ai_client_prompt()' ), matching how WordPress core signals class deprecation. The notice fires once per request via the singleton constructor rather than on everyget_instance()call.get_ai_service()now calls_deprecated_function( __FUNCTION__, 'x.x.x', 'wp_ai_client_prompt()' )before returning the instance.@deprecated x.x.xdocblock tags and updated descriptions pointing callers atwp_ai_client_prompt()directly, with a short snippet showing the one bit of behavior the helper added (applyingget_preferred_models_for_text_generation()by default).docs/ARCHITECTURE_OVERVIEW.mdnow notesAI_Serviceas deprecated in theServices/folder description.tests/Integration/Includes/Services/AI_ServiceTest.phpusessetExpectedDeprecated()around every call into the deprecated surface, so the suite fails if the deprecation notice goes missing or if an unexpected notice fires. The singleton is reset between tests via reflection so the notice (which the constructor only emits once per process) stays deterministic.Testing Instructions
tests/Integration/Includes/Services/AI_ServiceTest.phpshould pass and confirm deprecation notices fire correctly:composer testWP_DEBUGenabled, manually callWordPress\AI\get_ai_service()orAI_Service::get_instance()from a test snippet and confirm a deprecation notice is logged, while the returned instance still works (create_textgen_prompt()still returns a usable prompt builder).AI_Serviceorget_ai_service()outside the deprecated files themselves.Changelog Entry