| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
(no description)
| File Size: | 534 lines (23 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
EmbeddingBuilder:: (21 methods):
__construct()
__clone()
withInput()
usingModel()
usingProviderModel()
usingRequestOptions()
usingDimensions()
isSupported()
generateEmbeddingResult()
generateEmbedding()
generateEmbeddings()
resolveModel()
locateModel()
prepareModel()
effectiveModelConfig()
assertProviderConfigured()
describeUnmetRequirements()
describeOptionValue()
parseInput()
validatePart()
dispatchEvent()
Class: EmbeddingBuilder - X-Ref
Fluent builder for generating embeddings.| __construct(ProviderRegistry $registry, $input = null, ?EventDispatcherInterface $eventDispatcher = null) X-Ref |
| Constructor. param: ProviderRegistry $registry The provider registry used to prepare the model. param: EmbeddingInput|list<EmbeddingInput>|null $input Optional initial input(s) to embed. param: EventDispatcherInterface|null $eventDispatcher Optional event dispatcher for lifecycle events. |
| __clone() X-Ref |
| Creates a deep clone of this builder. Clones the inputs, model configuration, and request options. Service objects (registry, model, event dispatcher) are intentionally NOT cloned as they are shared dependencies. |
| withInput(...$input) X-Ref |
| Adds one or more inputs to embed. return: self param: EmbeddingInput ...$input The inputs to embed, each treated as an independent input. |
| usingModel(ModelInterface $model) X-Ref |
| Sets the model to use for embedding generation. The model's configuration will be merged with the builder's configuration, with the builder's configuration taking precedence for any overlapping settings. The merge happens when the model is used rather than here, so replacing the model replaces its configuration along with it. return: self param: ModelInterface $model The model to use. |
| usingProviderModel(string $providerIdOrClassName, string $modelId) X-Ref |
| Sets the model to use for embedding generation, by provider and model identifier. This is an alternative to {@see self::usingModel()} that does not require the caller to reference a provider class directly. The model is retrieved from the registry when the embeddings are generated, so it receives any configuration set afterwards. return: self param: string $providerIdOrClassName The provider ID or class name. param: string $modelId The model identifier. |
| usingRequestOptions(RequestOptions $requestOptions) X-Ref |
| Sets the request options for HTTP transport. return: self param: RequestOptions $requestOptions The request options. |
| usingDimensions(int $dimensions) X-Ref |
| Sets the embedding dimensions. return: self param: int $dimensions The embedding dimensions. |
| isSupported() X-Ref |
| Checks whether the specified model supports the current inputs and configuration. This reports whether the model set via {@see self::usingModel()} or {@see self::usingProviderModel()} can fulfill the request, rather than whether any available model can. Any reason the specified model cannot fulfill the request is reported as `false`, including an unregistered or unconfigured provider, a model ID the provider does not offer, and a provider that could not be reached. Only failing to specify a model at all is treated as a programming error and throws. A model instance provided via {@see self::usingModel()} is left untouched, so that checking for support does not alter it. Determining whether the model's provider is configured may require a request to the provider, which is cached for the remainder of the request. return: bool True if the specified model supports embedding generation for the current |
| generateEmbeddingResult() X-Ref |
| Generates an embedding result from the configured inputs. return: EmbeddingResult The generated embedding result. |
| generateEmbedding() X-Ref |
| Generates a single embedding from the configured input. return: Embedding The generated embedding vector. |
| generateEmbeddings() X-Ref |
| Generates embeddings from the configured inputs. return: list<Embedding> The generated embedding vectors. |
| resolveModel() X-Ref |
| Resolves the specified model and verifies it can fulfill the request. return: ModelInterface&EmbeddingGenerationModelInterface The verified model. |
| locateModel() X-Ref |
| Locates the specified model, without preparing it for use. Unlike {@see self::prepareModel()}, this leaves a model instance provided by the caller untouched, so that it can be inspected without altering it. return: ModelInterface The located model. |
| prepareModel() X-Ref |
| Prepares the specified model for use, without verifying that it can fulfill the request. return: ModelInterface The prepared model, with its dependencies and configuration bound. |
| effectiveModelConfig(ModelInterface $model) X-Ref |
| Combines a model's own configuration with the configuration set on this builder. The builder's configuration takes precedence for any overlapping settings. Combining happens here, when the model is used, rather than when the model is set, so that the configuration of a model that was subsequently replaced is not applied to its replacement. return: ModelConfig The effective configuration for the given model. param: ModelInterface $model The model whose configuration to combine with the builder's. |
| assertProviderConfigured(string $providerIdOrClassName) X-Ref |
| Asserts that the given provider is configured and therefore usable. return: void param: string $providerIdOrClassName The provider ID or class name. |
| describeUnmetRequirements(ModelInterface $model) X-Ref |
| Describes the requirements of the current request that the given model does not meet. return: string|null A description of the unmet requirements, or null if the model meets them all. param: ModelInterface $model The model to check. |
| describeOptionValue($value) X-Ref |
| Describes an option value for use in an error message. return: string The human readable description. param: mixed $value The option value to describe. |
| parseInput($input) X-Ref |
| Parses a single input into a message part. return: MessagePart The parsed message part. param: mixed $input The input to parse. Accepts a string, MessagePart, File, or |
| validatePart(MessagePart $part) X-Ref |
| Validates that a message part is a valid embedding input. return: MessagePart The validated part. param: MessagePart $part The part to validate. |
| dispatchEvent(object $event) X-Ref |
| Dispatches an event if an event dispatcher is registered. return: void param: object $event The event to dispatch. |
| Generated : Wed Oct 14 08:20:33 2026 | Cross-referenced by PHPXref |