Bring over latest embeddings code from the PHP AI Client - #975
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. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #975 +/- ##
=============================================
+ Coverage 74.57% 75.14% +0.56%
- Complexity 3132 3208 +76
=============================================
Files 132 133 +1
Lines 12213 12458 +245
=============================================
+ Hits 9108 9361 +253
+ Misses 3105 3097 -8
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:
|
|
With the upstream PR now merged, this PR has been updated with the latest code from that and is ready to be merged here |
Worth noting the drop in test coverage here is because most of the code in this PR comes straight from the PHP AI Client and I didn't bring any of the tests over. Since it's vendor code I figured the tests should live there but we could copy those over as well if we want to satisfy coverage |
What?
Part of #962
Brings over the latest embeddings code from the PHP AI Client and adds a temporary WP-CLI command to test that.
Why?
In #892 we brought over the embeddings code from the PHP AI Client into a custom
Vendordirectory, allowing us to start building on top of that prior to that being in WordPress. It was then decided that some changes were needed on that code (currently happening in WordPress/php-ai-client#274) and so we disabled the loading of that code prior to the last release of this plugin (see #946).While the upstream PR hasn't been merged yet, I think it's close so this PR gets us started on bringing over those latest changes and turning support back on.
In addition, a temporary WP-CLI command was brought back to easily test the changes here. Same as before, plan is to remove that prior to merge.
How?
Vendordirectorygenerate_embeddingshelper function to support the new approach (a model is required)SDK_Overlayclass again, which loads in our vendored PHP AI ClientUse of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 5 xHigh effort
Used for: Analyzing the changes made upstream and pulling those in as well as bringing back the removed WP-CLI command and adjusting everything accordingly to account for the new changes. 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'wp ai embeddings generate 'This is some text' --provider=openai --model=text-embedding-3-smallwp ai embeddings generate 'This is some text' --provider=openai --model=text-embedding-3-small --dry-run=falsewp ai embeddings generate --post-id=42 --provider=openai --model=text-embedding-3-small --dry-run=falsewp ai embeddings generate --post-id=42 --provider=openai --model=text-embedding-3-small --chunk --dry-run=falsewp ai embeddings generate 'This is some text' --provider=ollama --model=nomic-embed-text:latest --dry-run=falseChangelog Entry