assistant.php
1 year ago
assistfeedback.php
1 year ago
base.php
1 year ago
droppedfile.php
1 year ago
embed.php
1 year ago
feedback.php
1 year ago
function.php
1 year ago
image.php
1 year ago
parameter.php
2 years ago
text.php
1 year ago
transcribe.php
1 year ago
parameter.php
28 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( string $name, ?string $description, |
| 11 | ?string $type = "string", ?bool $required = false, ?string $default = null ) { |
| 12 | // $name: The name of the argument to be used. Must be a-z, A-Z, 0-9, or contain underscores, with a maximum length of 64, and can start with a dollar sign. |
| 13 | if ( !preg_match( '/^\$?[a-zA-Z0-9_]{1,64}$/', $name ) ) { |
| 14 | throw new InvalidArgumentException( "AI Engine: Invalid parameter name ($name) for Meow_MWAI_Query_Parameter." ); |
| 15 | } |
| 16 | |
| 17 | // Make sure the type is valid for JSON Schema. |
| 18 | if ( !in_array( $type, [ 'string', 'number', 'integer', 'boolean', 'array', 'object' ] ) ) { |
| 19 | throw new InvalidArgumentException( "AI Engine: Invalid parameter type ($type) for Meow_MWAI_Query_Parameter." ); |
| 20 | } |
| 21 | |
| 22 | $this->name = $name; |
| 23 | $this->description = empty( $description ) ? "" : $description; |
| 24 | $this->type = empty( $type ) ? 'string' : $type; |
| 25 | $this->required = empty( $required ) ? false : $required; |
| 26 | $this->default = $default; |
| 27 | } |
| 28 | } |