[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/php-ai-client/src/Results/DTO/ -> GenerativeAiResult.php (summary)

(no description)

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

Defines 1 class

GenerativeAiResult:: (25 methods):
  __construct()
  getId()
  getCandidates()
  getTokenUsage()
  getProviderMetadata()
  getModelMetadata()
  getAdditionalData()
  getCandidateCount()
  hasMultipleCandidates()
  toText()
  toFile()
  toImageFile()
  toAudioFile()
  toVideoFile()
  toMessage()
  toTexts()
  toFiles()
  toImageFiles()
  toAudioFiles()
  toVideoFiles()
  toMessages()
  getJsonSchema()
  toArray()
  fromArray()
  __clone()


Class: GenerativeAiResult  - X-Ref

Represents the result of a generative AI operation.

This DTO contains the generated candidates along with usage statistics
and metadata from the AI provider.

__construct(string $id, array $candidates, \WordPress\AiClient\Results\DTO\TokenUsage $tokenUsage, ProviderMetadata $providerMetadata, ModelMetadata $modelMetadata, array $additionalData = [])   X-Ref
Constructor.

param: string $id Unique identifier for this result.
param: Candidate[] $candidates The generated candidates.
param: TokenUsage $tokenUsage Token usage statistics.
param: ProviderMetadata $providerMetadata Provider metadata.
param: ModelMetadata $modelMetadata Model metadata.
param: array<string, mixed> $additionalData Additional data.

getId()   X-Ref
{@inheritDoc}


getCandidates()   X-Ref
Gets the generated candidates.

return: Candidate[] The candidates.

getTokenUsage()   X-Ref
{@inheritDoc}


getProviderMetadata()   X-Ref
Gets the provider metadata.

return: ProviderMetadata The provider metadata.

getModelMetadata()   X-Ref
Gets the model metadata.

return: ModelMetadata The model metadata.

getAdditionalData()   X-Ref
{@inheritDoc}


getCandidateCount()   X-Ref
Gets the total number of candidates.

return: int The total number of candidates.

hasMultipleCandidates()   X-Ref
Checks if the result has multiple candidates.

return: bool True if there are multiple candidates, false otherwise.

toText()   X-Ref
Converts the first candidate to text.

Only text from the content channel is considered. Text within model thought or reasoning is ignored.

return: string The text content.

toFile()   X-Ref
Converts the first candidate to a file.

Only files from the content channel are considered. Files within model thought or reasoning are ignored.

return: File The file.

toImageFile()   X-Ref
Converts the first candidate to an image file.

return: File The image file.

toAudioFile()   X-Ref
Converts the first candidate to an audio file.

return: File The audio file.

toVideoFile()   X-Ref
Converts the first candidate to a video file.

return: File The video file.

toMessage()   X-Ref
Converts the first candidate to a message.

return: Message The message.

toTexts()   X-Ref
Converts all candidates to text.

return: list<string> Array of text content.

toFiles()   X-Ref
Converts all candidates to files.

return: list<File> Array of files.

toImageFiles()   X-Ref
Converts all candidates to image files.

return: list<File> Array of image files.

toAudioFiles()   X-Ref
Converts all candidates to audio files.

return: list<File> Array of audio files.

toVideoFiles()   X-Ref
Converts all candidates to video files.

return: list<File> Array of video files.

toMessages()   X-Ref
Converts all candidates to messages.

return: list<Message> Array of messages.

getJsonSchema()   X-Ref
{@inheritDoc}


toArray()   X-Ref
{@inheritDoc}

return: GenerativeAiResultArrayShape

fromArray(array $array)   X-Ref
{@inheritDoc}


__clone()   X-Ref
Performs a deep clone of the result.

This method ensures that all nested objects (candidates, token usage, metadata)
are cloned to prevent modifications to the cloned result from affecting the original.




Generated : Sat Jun 13 09:38:55 2026 Cross-referenced by PHPXref