[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ai-client/ -> class-wp-ai-client-embedding-builder.php (summary)

WP AI Client: WP_AI_Client_Embedding_Builder class

File Size: 165 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_AI_Client_Embedding_Builder:: (6 methods):
  create_sdk_builder()
  get_error_code_prefix()
  get_prevented_error_message()
  is_prevented_by_filter()
  get_generating_methods()
  get_support_check_methods()


Class: WP_AI_Client_Embedding_Builder  - X-Ref

Fluent builder for generating embeddings, returning WP_Error on failure.

This class provides a fluent interface for generating embedding vectors from
text or file inputs. It wraps the PHP AI Client SDK's EmbeddingBuilder and
adds WordPress-specific behavior including WP_Error handling instead of
exceptions and snake_case method naming.

A model must be specified 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.

Only the generating methods will return a WP_Error, to not break the fluent
interface. As soon as any exception is caught in a chain of method calls,
the returned instance will be in an error state, and all subsequent method
calls will be no-ops that just return the same error state instance. Only
when a generating method is called, the WP_Error will be returned. The
support check methods are the exception to the no-op behavior: they return
false rather than the error state instance.

create_sdk_builder( ProviderRegistry $registry, $input )   X-Ref
Creates the wrapped embedding builder instance from the PHP AI Client SDK.

return: EmbeddingBuilder The SDK embedding builder instance.
param: ProviderRegistry                         $registry The provider registry for finding suitable models.
param: EmbeddingInput|list<EmbeddingInput>|null $input    Initial input(s) to embed, or null.

get_error_code_prefix()   X-Ref
Retrieves the prefix used for WP_Error codes created by this builder.

return: string The error code prefix.

get_prevented_error_message()   X-Ref
Retrieves the error message to use when the embedding generation is prevented by a filter.

return: string The translated error message.

is_prevented_by_filter()   X-Ref
Checks whether the embedding generation is prevented by the `wp_ai_client_prevent_embedding` filter.

return: bool Whether the embedding generation is prevented.

get_generating_methods()   X-Ref
Retrieves the methods that generate embeddings from the inputs.

return: array<string, bool> The generating methods map.

get_support_check_methods()   X-Ref
Retrieves the methods that check whether the embedding generation is supported.

return: array<string, bool> The support check methods map.



Generated : Wed Oct 14 08:20:33 2026 Cross-referenced by PHPXref