Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
5697d61
AI: Update bundled PHP AI Client library to 1.4.0.
JasonTheAdams Jul 15, 2026
0f04a22
AI: Introduce WP_AI_Client_Embedding_Builder for generating embeddings.
JasonTheAdams Jul 15, 2026
1b8d8a5
AI: Fix prompt builder tests for PHP AI Client 1.4.0 property moves.
JasonTheAdams Jul 15, 2026
efeb6ed
AI: Extract shared builder behavior into WP_AI_Client_Builder base cl…
JasonTheAdams Jul 15, 2026
df674f8
AI: Pass the builder type to the wp_ai_client_default_request_timeout…
JasonTheAdams Jul 15, 2026
f4233d1
AI: Add tests for WP_AI_Client_Embedding_Builder and wp_ai_client_emb…
JasonTheAdams Jul 15, 2026
f9e2ffb
Merge branch 'trunk' into update/php-ai-client-1.4.0
claude Oct 9, 2026
316ca31
AI: Port recent prompt builder fixes to WP_AI_Client_Builder.
claude Oct 9, 2026
524974d
AI: Update `@since` tags from 7.1.0 to 7.2.0.
claude Oct 9, 2026
14fdd4b
AI: Update bundled PHP AI Client library to 1.5.0.
claude Oct 9, 2026
b9ad271
AI: Require an explicit model in WP_AI_Client_Embedding_Builder.
claude Oct 9, 2026
b47a0e4
Merge branch 'trunk' into update/php-ai-client-1.4.0
gziolo Oct 12, 2026
32956e9
AI: Accept a list of inputs in wp_ai_client_embedding().
claude Oct 12, 2026
5675b4c
AI: Test the embedding lifecycle action hooks.
claude Oct 12, 2026
d457fe5
Tests: Reference the embedding ticket in the new AI client tests.
claude Oct 12, 2026
f83123e
AI: Keep WP_AI_Client_Builder internals private.
claude Oct 12, 2026
1824a0c
Tests: Prefer behavior over private members in embedding builder tests.
claude Oct 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/wp-includes/ai-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

use WordPress\AiClient\AiClient;
use WordPress\AiClient\Files\DTO\File;
use WordPress\AiClient\Messages\DTO\Message;
use WordPress\AiClient\Messages\DTO\MessagePart;

Expand Down Expand Up @@ -60,3 +61,40 @@ function wp_supports_ai(): bool {
function wp_ai_client_prompt( $prompt = null ): WP_AI_Client_Prompt_Builder {
return new WP_AI_Client_Prompt_Builder( AiClient::defaultRegistry(), $prompt );
}

/**
* Creates a new AI embedding builder using the default provider registry.
*
* This is the main entry point for generating embeddings in WordPress. It returns
* a fluent builder that can be used to configure and generate embedding vectors.
*
* Each input can be provided as a simple string for basic text inputs, or as more
* complex types. Pass multiple arguments, or a single list of inputs, to embed
* multiple inputs at once, each producing its own embedding vector.
*
* A model must be specified on the returned builder via `using_model()` or
* `using_provider_model()`. Embedding vectors are only comparable to other
* vectors produced by the same model, so no model is selected automatically.
*
* @since 7.2.0
*
* @param string|MessagePart|File|array ...$input Optional. Initial input(s) to embed.
* A string for simple text inputs,
* a MessagePart or File object for
* structured content, or an array for
* a message part array shape.
* Alternatively, a single list of any
* of these to embed multiple inputs.
* @return WP_AI_Client_Embedding_Builder The embedding builder instance.
*/
function wp_ai_client_embedding( ...$input ): WP_AI_Client_Embedding_Builder {
/*
* A single list argument is a list of inputs. It cannot be a single input, since
* the only array input is a message part array shape, which is never a list.
*/
if ( 1 === count( $input ) && isset( $input[0] ) && is_array( $input[0] ) && array_is_list( $input[0] ) ) {
$input = $input[0];
}

return new WP_AI_Client_Embedding_Builder( AiClient::defaultRegistry(), array() === $input ? null : $input );
Comment thread
JasonTheAdams marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ public function dispatch( object $event ): object {
*
* - wp_ai_client_before_generate_result
* - wp_ai_client_after_generate_result
* - wp_ai_client_before_generate_embedding
* - wp_ai_client_after_generate_embedding
*
* @since 7.0.0
* @since 7.2.0 Added the `wp_ai_client_before_generate_embedding` and
* `wp_ai_client_after_generate_embedding` action hooks.
*
* @param object $event The event object.
*/
Expand Down
Loading
Loading