Skip to content

Commit 48a4c79

Browse files
committed
Include outputFileType param for model config.
1 parent 797fb9d commit 48a4c79

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/Providers/Models/DTO/ModelConfig.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use InvalidArgumentException;
88
use WordPress\AiClient\Common\AbstractDataTransferObject;
9+
use WordPress\AiClient\Files\Enums\FileTypeEnum;
910
use WordPress\AiClient\Messages\Enums\ModalityEnum;
1011
use WordPress\AiClient\Tools\DTO\Tool;
1112

@@ -56,6 +57,7 @@ class ModelConfig extends AbstractDataTransferObject
5657
public const KEY_LOGPROBS = 'logprobs';
5758
public const KEY_TOP_LOGPROBS = 'topLogprobs';
5859
public const KEY_TOOLS = 'tools';
60+
public const KEY_OUTPUT_FILE_TYPE = 'outputFileType';
5961
public const KEY_OUTPUT_MIME_TYPE = 'outputMimeType';
6062
public const KEY_OUTPUT_SCHEMA = 'outputSchema';
6163
public const KEY_CUSTOM_OPTIONS = 'customOptions';
@@ -125,6 +127,11 @@ class ModelConfig extends AbstractDataTransferObject
125127
*/
126128
protected ?array $tools = null;
127129

130+
/**
131+
* @var FileTypeEnum|null Output file type.
132+
*/
133+
protected ?FileTypeEnum $outputFileType = null;
134+
128135
/**
129136
* @var string|null Output MIME type.
130137
*/
@@ -470,6 +477,30 @@ public function getTools(): ?array
470477
return $this->tools;
471478
}
472479

480+
/**
481+
* Sets the output file type.
482+
*
483+
* @since n.e.x.t
484+
*
485+
* @param FileTypeEnum $outputFileType The output file type.
486+
*/
487+
public function setOutputFileType(FileTypeEnum $outputFileType): void
488+
{
489+
$this->outputFileType = $outputFileType;
490+
}
491+
492+
/**
493+
* Gets the output file type.
494+
*
495+
* @since n.e.x.t
496+
*
497+
* @return FileTypeEnum|null The output file type.
498+
*/
499+
public function getOutputFileType(): ?FileTypeEnum
500+
{
501+
return $this->outputFileType;
502+
}
503+
473504
/**
474505
* Sets the output MIME type.
475506
*
@@ -641,6 +672,11 @@ public static function getJsonSchema(): array
641672
'items' => Tool::getJsonSchema(),
642673
'description' => 'Tools available to the model.',
643674
],
675+
self::KEY_OUTPUT_FILE_TYPE => [
676+
'type' => 'string',
677+
'enum' => FileTypeEnum::getValues(),
678+
'description' => 'Output file type.',
679+
],
644680
self::KEY_OUTPUT_MIME_TYPE => [
645681
'type' => 'string',
646682
'description' => 'Output MIME type.',
@@ -730,6 +766,10 @@ static function (ModalityEnum $modality): string {
730766
}, $this->tools);
731767
}
732768

769+
if ($this->outputFileType !== null) {
770+
$data[self::KEY_OUTPUT_FILE_TYPE] = $this->outputFileType->value;
771+
}
772+
733773
if ($this->outputMimeType !== null) {
734774
$data[self::KEY_OUTPUT_MIME_TYPE] = $this->outputMimeType;
735775
}
@@ -809,6 +849,15 @@ public static function fromArray(array $array): self
809849
}, $array[self::KEY_TOOLS]));
810850
}
811851

852+
if (isset($array[self::KEY_OUTPUT_FILE_TYPE])) {
853+
if (!is_string($array[self::KEY_OUTPUT_FILE_TYPE])) {
854+
throw new InvalidArgumentException(
855+
'Output file type must be a string.'
856+
);
857+
}
858+
$config->setOutputFileType(FileTypeEnum::from($array[self::KEY_OUTPUT_FILE_TYPE]));
859+
}
860+
812861
if (isset($array[self::KEY_OUTPUT_MIME_TYPE])) {
813862
$config->setOutputMimeType($array[self::KEY_OUTPUT_MIME_TYPE]);
814863
}

0 commit comments

Comments
 (0)