Skip to content

Bring over latest embeddings code from the PHP AI Client - #975

Merged
jeffpaul merged 8 commits into
WordPress:developfrom
dkotter:feature/update-embedding-client
Aug 31, 2026
Merged

Bring over latest embeddings code from the PHP AI Client#975
jeffpaul merged 8 commits into
WordPress:developfrom
dkotter:feature/update-embedding-client

Conversation

@dkotter

@dkotter dkotter commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

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 Vendor directory, 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?

Use 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.

  1. Pull this PR down
  2. Ensure you have an AI Provider plugin installed, activated and configured that supports embeddings: OpenAI and Ollama released support in the last version; Google PR
  3. Open up a terminal window
  4. Run wp ai embeddings generate 'This is some text'
  5. You should get a message around missing a model and provider
  6. Run wp ai embeddings generate 'This is some text' --provider=openai --model=text-embedding-3-small
  7. You should get a message about being in dry run mode
  8. Run wp ai embeddings generate 'This is some text' --provider=openai --model=text-embedding-3-small --dry-run=false
  9. You should see a success message and information about the provider and model used as well as the embedding value (trimmed)
  10. Try other versions of the command and ensure they work as expected:
  • wp ai embeddings generate --post-id=42 --provider=openai --model=text-embedding-3-small --dry-run=false
  • wp ai embeddings generate --post-id=42 --provider=openai --model=text-embedding-3-small --chunk --dry-run=false
  • wp ai embeddings generate 'This is some text' --provider=ollama --model=nomic-embed-text:latest --dry-run=false

Changelog Entry

Changed - Update to the latest version of the embedding code from the PHP AI Client.

Changed - Our generate_embeddings helper function now requires a specific embedding model. Pass model (a model ID or a ModelInterface instance) and, for a model ID, the provider that offers it. This is a breaking change for anyone that happened to start using this function.

Open WordPress Playground Preview

@dkotter dkotter added this to the 1.4.0 milestone Aug 25, 2026
@dkotter dkotter self-assigned this Aug 25, 2026
@dkotter
dkotter requested a review from a team August 25, 2026 20:52
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: ColinM-sys <colinmcdonough@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@dkotter dkotter added the [Status] Blocked Used to indicate unable to move forward label Aug 25, 2026
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 13.31058% with 254 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.14%. Comparing base (eaeb7f2) to head (61f0993).

Files with missing lines Patch % Lines
includes/CLI/Embeddings_Command.php 0.00% 140 Missing ⚠️
.../Vendor/AiClient/src/Builders/EmbeddingBuilder.php 21.18% 93 Missing ⚠️
...ent/src/Providers/Models/DTO/ModelRequirements.php 0.00% 13 Missing ⚠️
...nt/src/Builders/Traits/ModelConfigurationTrait.php 0.00% 6 Missing ⚠️
includes/Main.php 66.66% 1 Missing ⚠️
includes/helpers.php 92.30% 1 Missing ⚠️
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     
Flag Coverage Δ
unit 75.14% <13.31%> (+0.56%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jeffpaul jeffpaul linked an issue Aug 31, 2026 that may be closed by this pull request
7 tasks
@dkotter dkotter removed the [Status] Blocked Used to indicate unable to move forward label Aug 31, 2026
@dkotter
dkotter requested a review from jeffpaul August 31, 2026 18:52
@dkotter

dkotter commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

With the upstream PR now merged, this PR has been updated with the latest code from that and is ready to be merged here

@jeffpaul jeffpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting the drop in test coverage, but can circle back to that separately and not block getting this work in as foundational for a bunch of other tasks noted in #962.

@jeffpaul
jeffpaul merged commit 7d0c3ff into WordPress:develop Aug 31, 2026
32 of 33 checks passed
@dkotter

dkotter commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Noting the drop in test coverage, but can circle back to that separately and not block getting this work in as foundational for a bunch of other tasks noted in #962.

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

@dkotter
dkotter deleted the feature/update-embedding-client branch August 31, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tracking: Implement Embedding Support

2 participants