WordPress\AiClient\Builders

PromptBuilder::withFilepublicWP 0.1.0

Adds a file to the current message.

Accepts:

  • File object
  • URL string (remote file)
  • Base64-encoded data string
  • Data URI string (data:mime/type;base64,data)
  • Local file path string

Method of the class: PromptBuilder{}

No Hooks.

Returns

self.

Usage

$PromptBuilder = new PromptBuilder();
$PromptBuilder->withFile( $file, ?string $mimeType ): self;
$file(string|File) (required)
The file (File object or string representation).
?string $mimeType
.
Default: null

Changelog

Since 0.1.0 Introduced.

PromptBuilder::withFile() code WP 7.0

public function withFile($file, ?string $mimeType = null): self
{
    $file = $file instanceof File ? $file : new File($file, $mimeType);
    $part = new MessagePart($file);
    $this->appendPartToMessages($part);
    return $this;
}