assistant.php
2 years ago
base.php
2 years ago
embed.php
2 years ago
function.php
2 years ago
image.php
2 years ago
parameter.php
2 years ago
text.php
2 years ago
transcribe.php
2 years ago
image.php
41 lines
| 1 | <?php |
| 2 | |
| 3 | class Meow_MWAI_Query_Image extends Meow_MWAI_Query_Base { |
| 4 | public ?string $resolution = '1792x1024'; |
| 5 | public ?string $style = null; |
| 6 | |
| 7 | public function __construct( ?string $message = "", ?string $model = "dall-e-3" ) { |
| 8 | parent::__construct( $message ); |
| 9 | $this->model = $model; |
| 10 | $this->mode = "generation"; // could be generation, edit, variation |
| 11 | } |
| 12 | |
| 13 | public function set_resolution( string $resolution ) { |
| 14 | $this->resolution = $resolution; |
| 15 | } |
| 16 | |
| 17 | public function set_style( string $style ) { |
| 18 | $this->style = $style; |
| 19 | } |
| 20 | |
| 21 | // Based on the params of the query, update the attributes |
| 22 | public function inject_params( array $params ): void { |
| 23 | parent::inject_params( $params ); |
| 24 | $params = $this->convert_keys( $params ); |
| 25 | |
| 26 | if ( !empty( $params['resolution'] ) ) { |
| 27 | $this->set_resolution( $params['resolution'] ); |
| 28 | } |
| 29 | if ( !empty( $params['style'] ) ) { |
| 30 | $this->set_style( $params['style'] ); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | public function final_checks() { |
| 35 | parent::final_checks(); |
| 36 | // Since DALL-E 3 only support 1 image, we force it. I guess it will be the same for other models. |
| 37 | $this->maxResults = 1; |
| 38 | } |
| 39 | |
| 40 | } |
| 41 |