assist-feedback.php
10 months ago
assistant.php
6 months ago
base.php
6 months ago
dropped-file.php
3 months ago
edit-image.php
3 months ago
embed.php
3 months ago
feedback.php
10 months ago
function.php
8 months ago
image.php
6 months ago
parameter.php
11 months ago
text.php
6 months ago
transcribe.php
8 months ago
parameter.php
33 lines
| 1 | <?php |
| 2 | |
| 3 | class Meow_MWAI_Query_Parameter { |
| 4 | public string $name; |
| 5 | public ?string $description; |
| 6 | public ?string $type; |
| 7 | public ?bool $required; |
| 8 | public ?string $default; |
| 9 | |
| 10 | public function __construct( |
| 11 | string $name, |
| 12 | ?string $description, |
| 13 | ?string $type = 'string', |
| 14 | ?bool $required = false, |
| 15 | ?string $default = null |
| 16 | ) { |
| 17 | |
| 18 | // Make sure the name is valid for JSON Schema |
| 19 | if ( !preg_match( '/^\$?[a-zA-Z0-9_]{1,64}$/', $name ) ) { |
| 20 | Meow_MWAI_Logging::error( "AI Engine: Invalid parameter name ($name) for Meow_MWAI_Query_Parameter." ); |
| 21 | } |
| 22 | if ( !in_array( $type, [ 'string', 'number', 'integer', 'boolean', 'array', 'object' ] ) ) { |
| 23 | Meow_MWAI_Logging::error( "AI Engine: Invalid parameter type ($type) for Meow_MWAI_Query_Parameter." ); |
| 24 | } |
| 25 | |
| 26 | $this->name = $name; |
| 27 | $this->description = empty( $description ) ? '' : $description; |
| 28 | $this->type = empty( $type ) ? 'string' : $type; |
| 29 | $this->required = empty( $required ) ? false : $required; |
| 30 | $this->default = $default; |
| 31 | } |
| 32 | } |
| 33 |