Skip to content

Commit a6a83cb

Browse files
committed
Add MediaOrientationEnum and include outputMediaOrientation param for model config.
1 parent 65351a7 commit a6a83cb

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace WordPress\AiClient\Files\Enums;
6+
7+
use WordPress\AiClient\Common\AbstractEnum;
8+
9+
/**
10+
* Represents the type of file storage.
11+
*
12+
* @method static self square() Returns the square orientation
13+
* @method static self landscape() Returns the landscape orientation.
14+
* @method static self portrait() Returns the portrait orientation.
15+
* @method bool isSquare() Checks if this is an square orientation
16+
* @method bool isLandscape() Checks if this is a landscape orientation.
17+
* @method bool isPortrait() Checks if this is a portrait orientation.
18+
*
19+
* @since n.e.x.t
20+
*/
21+
class MediaOrientationEnum extends AbstractEnum
22+
{
23+
/**
24+
* Square orientation.
25+
*
26+
* @var string
27+
*/
28+
public const SQUARE = 'square';
29+
30+
/**
31+
* Landscape orientation.
32+
*
33+
* @var string
34+
*/
35+
public const LANDSCAPE = 'landscape';
36+
37+
/**
38+
* Portrait orientation.
39+
*
40+
* @var string
41+
*/
42+
public const PORTRAIT = 'portrait';
43+
}

src/Providers/Models/DTO/ModelConfig.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use InvalidArgumentException;
88
use WordPress\AiClient\Common\AbstractDataTransferObject;
99
use WordPress\AiClient\Files\Enums\FileTypeEnum;
10+
use WordPress\AiClient\Files\Enums\MediaOrientationEnum;
1011
use WordPress\AiClient\Messages\Enums\ModalityEnum;
1112
use WordPress\AiClient\Tools\DTO\Tool;
1213

@@ -38,6 +39,7 @@
3839
* outputFileType?: string,
3940
* outputMimeType?: string,
4041
* outputSchema?: array<string, mixed>,
42+
* outputMediaOrientation?: string,
4143
* customOptions?: array<string, mixed>
4244
* }
4345
*
@@ -61,6 +63,7 @@ class ModelConfig extends AbstractDataTransferObject
6163
public const KEY_OUTPUT_FILE_TYPE = 'outputFileType';
6264
public const KEY_OUTPUT_MIME_TYPE = 'outputMimeType';
6365
public const KEY_OUTPUT_SCHEMA = 'outputSchema';
66+
public const KEY_OUTPUT_MEDIA_ORIENTATION = 'outputMediaOrientation';
6467
public const KEY_CUSTOM_OPTIONS = 'customOptions';
6568

6669
/**
@@ -143,6 +146,11 @@ class ModelConfig extends AbstractDataTransferObject
143146
*/
144147
protected ?array $outputSchema = null;
145148

149+
/**
150+
* @var MediaOrientationEnum|null Output media orientation.
151+
*/
152+
protected ?MediaOrientationEnum $outputMediaOrientation = null;
153+
146154
/**
147155
* @var array<string, mixed> Custom provider-specific options.
148156
*/
@@ -558,6 +566,30 @@ public function getOutputSchema(): ?array
558566
return $this->outputSchema;
559567
}
560568

569+
/**
570+
* Sets the output media orientation.
571+
*
572+
* @since n.e.x.t
573+
*
574+
* @param MediaOrientationEnum $outputMediaOrientation The output media orientation.
575+
*/
576+
public function setOutputMediaOrientation(MediaOrientationEnum $outputMediaOrientation): void
577+
{
578+
$this->outputMediaOrientation = $outputMediaOrientation;
579+
}
580+
581+
/**
582+
* Gets the output media orientation.
583+
*
584+
* @since n.e.x.t
585+
*
586+
* @return MediaOrientationEnum|null The output media orientation.
587+
*/
588+
public function getOutputMediaOrientation(): ?MediaOrientationEnum
589+
{
590+
return $this->outputMediaOrientation;
591+
}
592+
561593
/**
562594
* Sets a single custom option.
563595
*
@@ -687,6 +719,11 @@ public static function getJsonSchema(): array
687719
'additionalProperties' => true,
688720
'description' => 'Output schema (JSON schema).',
689721
],
722+
self::KEY_OUTPUT_MEDIA_ORIENTATION => [
723+
'type' => 'string',
724+
'enum' => MediaOrientationEnum::getValues(),
725+
'description' => 'Output media orientation.',
726+
],
690727
self::KEY_CUSTOM_OPTIONS => [
691728
'type' => 'object',
692729
'additionalProperties' => true,
@@ -779,6 +816,10 @@ static function (ModalityEnum $modality): string {
779816
$data[self::KEY_OUTPUT_SCHEMA] = $this->outputSchema;
780817
}
781818

819+
if ($this->outputMediaOrientation !== null) {
820+
$data[self::KEY_OUTPUT_MEDIA_ORIENTATION] = $this->outputMediaOrientation->value;
821+
}
822+
782823
$data[self::KEY_CUSTOM_OPTIONS] = $this->customOptions;
783824

784825
return $data;
@@ -862,6 +903,10 @@ public static function fromArray(array $array): self
862903
$config->setOutputSchema($array[self::KEY_OUTPUT_SCHEMA]);
863904
}
864905

906+
if (isset($array[self::KEY_OUTPUT_MEDIA_ORIENTATION])) {
907+
$config->setOutputMediaOrientation(MediaOrientationEnum::from($array[self::KEY_OUTPUT_MEDIA_ORIENTATION]));
908+
}
909+
865910
if (isset($array[self::KEY_CUSTOM_OPTIONS])) {
866911
$config->setCustomOptions($array[self::KEY_CUSTOM_OPTIONS]);
867912
}

0 commit comments

Comments
 (0)