wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_ai_client_embedding › WordPress Function

Seit7.2.0
Veraltetn/v
› wp_ai_client_embedding ( $input )
Parameter:
  • (string|WordPressAiClientMessagesDTOMessagePart|WordPressAiClientFilesDTOFile|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.
    Erforderlich: Ja
Gibt zurück:
  • (WP_AI_Client_Embedding_Builder) The embedding builder instance.
Definiert in:
Codex:

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.


Quellcode

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 );
}