Bring over embeddings support from the PHP AI Client - #892
Conversation
…r custom Vendor directory
…om us instead of Core if needed
…and to also generate embeddings
…. May remove before merging the PR
…Client things in the future we want to load, those can all be handled independently of one another
|
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❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #892 +/- ##
=============================================
- Coverage 79.74% 73.92% -5.82%
- Complexity 2469 2840 +371
=============================================
Files 104 115 +11
Lines 9992 11162 +1170
=============================================
+ Hits 7968 8252 +284
- Misses 2024 2910 +886
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:
|
What?
Brings the embedding related changes over from the PHP AI Client and loads those conditionally when needed, allowing us to start supporting that work.
Why?
Embedding supported was added to v1.4.0 of the PHP AI Client. We were hoping to get this in to WordPress 7.1 but that has been pushed now to 7.2. Instead of having to wait until WordPress 7.2 is released to take advantage of this new functionality, this PR pulls that code into the AI plugin, behind a conditional gate, so we can start taking advantage of that earlier.
How?
includes/Vendor/AiClientdirectorySDK_Overlayclass that loads this code, if needed, on top of the code WordPress itself loads. This allows us to continue to use the PHP AI Client that ships with WordPress while also loading in this new embedding code. This approach can be used in the future for any other PHP AI Client changes we want to start using soonerUse of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.8
Used for: Brainstorming and planning the initial approach and then executing on that approach. Final review and testing by me
Testing Instructions
Easiest way to test is via the custom WP-CLI command this PR has. Note you'll also need to install an AI Provider plugin that supports embeddings.
wp ai embeddings generate 'This is some text'Dry run: would have generated embeddings for text: This is some textwp ai embeddings generate 'This is some text' --dry-run=falsewp ai embeddings generate --post-id=42 --dry-run=falsewp ai embeddings generate --post-id=42 --chunk --dry-run=falsewp ai embeddings generate 'This is some text' --provider=ollama --dry-run=falseChangelog Entry