Skip to content

Bring over embeddings support from the PHP AI Client - #892

Open
dkotter wants to merge 8 commits into
WordPress:developfrom
dkotter:feature/embeddings-client-support
Open

Bring over embeddings support from the PHP AI Client#892
dkotter wants to merge 8 commits into
WordPress:developfrom
dkotter:feature/embeddings-client-support

Conversation

@dkotter

@dkotter dkotter commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

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?

  • Pulls the embedding related code from the PHP AI Client into an includes/Vendor/AiClient directory
  • Adds an SDK_Overlay class 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 sooner
  • Adds in helper functions that can be used to determine if embedding generation is supported via the PHP AI Client and can be used to generate embeddings
  • Temporarily adds a custom WP-CLI command that can be used to test embedding functionality. Plan is to remove this prior to merge as it doesn't really provide any value outside of testing

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

  1. Pull this PR down
  2. Ensure you have an AI Provider plugin installed, activated and configured that supports embeddings: OpenAI PR, Google PR, Ollama PR
  3. Open up a terminal window
  4. Run wp ai embeddings generate 'This is some text'
  5. You should get a message like Dry run: would have generated embeddings for text: This is some text
  6. Run wp ai embeddings generate 'This is some text' --dry-run=false
  7. You should see a success message and information about the provider and model used as well as the embedding value (trimmed)
  8. Try other versions of the command and ensure they work as expected:
  • wp ai embeddings generate --post-id=42 --dry-run=false
  • wp ai embeddings generate --post-id=42 --chunk --dry-run=false
  • wp ai embeddings generate 'This is some text' --provider=ollama --dry-run=false

Changelog Entry

Added - Brought the embedding code over from the PHP AI Client and load that conditionally so those using the AI plugin can start to take advantage of embedding generation.

Open WordPress Playground Preview

@dkotter dkotter added this to the 1.3.0 milestone Jul 23, 2026
@dkotter dkotter self-assigned this Jul 23, 2026
@dkotter
dkotter requested a review from a team July 23, 2026 19:36
@github-actions

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>

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

@dkotter dkotter changed the title Feature/embeddings client support Bring over embeddings support from the PHP AI Client Jul 23, 2026
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 24.27350% with 886 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.92%. Comparing base (f0764fb) to head (c4c8fb8).

Files with missing lines Patch % Lines
.../AiClient/src/Providers/Models/DTO/ModelConfig.php 31.35% 243 Missing ⚠️
includes/CLI/Embeddings_Command.php 0.00% 125 Missing ⚠️
...es/Vendor/AiClient/src/Providers/ModelResolver.php 14.81% 115 Missing ⚠️
...ent/src/Providers/Models/DTO/ModelRequirements.php 45.22% 109 Missing ⚠️
...endor/AiClient/src/Results/DTO/EmbeddingResult.php 0.00% 104 Missing ⚠️
.../Vendor/AiClient/src/Builders/EmbeddingBuilder.php 27.16% 59 Missing ⚠️
...udes/Vendor/AiClient/src/Results/DTO/Embedding.php 0.00% 40 Missing ⚠️
includes/Vendor/AiClient/SDK_Overlay.php 51.72% 28 Missing ⚠️
...lient/src/Builders/Traits/ModelResolutionTrait.php 0.00% 22 Missing ⚠️
...iClient/src/Events/AfterGenerateEmbeddingEvent.php 0.00% 19 Missing ⚠️
... and 3 more
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     
Flag Coverage Δ
unit 73.92% <24.27%> (-5.82%) ⬇️

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.

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.

1 participant