| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 3 declare (strict_types=1); 4 namespace WordPress\AiClient\Providers\Models\Enums; 5 6 use ReflectionClass; 7 use WordPress\AiClient\Common\AbstractEnum; 8 use WordPress\AiClient\Providers\Models\DTO\ModelConfig; 9 /** 10 * Enum for model options. 11 * 12 * This enum dynamically includes all options from ModelConfig KEY_* constants 13 * in addition to the explicitly defined constants below. 14 * 15 * Explicitly defined option (not in ModelConfig): 16 * @method static self inputModalities() Creates an instance for INPUT_MODALITIES option. 17 * @method bool isInputModalities() Checks if the option is INPUT_MODALITIES. 18 * 19 * Dynamically loaded from ModelConfig KEY_* constants: 20 * @method static self candidateCount() Creates an instance for CANDIDATE_COUNT option. 21 * @method static self customOptions() Creates an instance for CUSTOM_OPTIONS option. 22 * @method static self dimensions() Creates an instance for DIMENSIONS option. 23 * @method static self frequencyPenalty() Creates an instance for FREQUENCY_PENALTY option. 24 * @method static self functionDeclarations() Creates an instance for FUNCTION_DECLARATIONS option. 25 * @method static self logprobs() Creates an instance for LOGPROBS option. 26 * @method static self maxTokens() Creates an instance for MAX_TOKENS option. 27 * @method static self outputFileType() Creates an instance for OUTPUT_FILE_TYPE option. 28 * @method static self outputMediaAspectRatio() Creates an instance for OUTPUT_MEDIA_ASPECT_RATIO option. 29 * @method static self outputMediaOrientation() Creates an instance for OUTPUT_MEDIA_ORIENTATION option. 30 * @method static self outputMimeType() Creates an instance for OUTPUT_MIME_TYPE option. 31 * @method static self outputModalities() Creates an instance for OUTPUT_MODALITIES option. 32 * @method static self outputSchema() Creates an instance for OUTPUT_SCHEMA option. 33 * @method static self outputSpeechVoice() Creates an instance for OUTPUT_SPEECH_VOICE option. 34 * @method static self presencePenalty() Creates an instance for PRESENCE_PENALTY option. 35 * @method static self stopSequences() Creates an instance for STOP_SEQUENCES option. 36 * @method static self systemInstruction() Creates an instance for SYSTEM_INSTRUCTION option. 37 * @method static self temperature() Creates an instance for TEMPERATURE option. 38 * @method static self topK() Creates an instance for TOP_K option. 39 * @method static self topLogprobs() Creates an instance for TOP_LOGPROBS option. 40 * @method static self topP() Creates an instance for TOP_P option. 41 * @method static self webSearch() Creates an instance for WEB_SEARCH option. 42 * @method bool isCandidateCount() Checks if the option is CANDIDATE_COUNT. 43 * @method bool isCustomOptions() Checks if the option is CUSTOM_OPTIONS. 44 * @method bool isDimensions() Checks if the option is DIMENSIONS. 45 * @method bool isFrequencyPenalty() Checks if the option is FREQUENCY_PENALTY. 46 * @method bool isFunctionDeclarations() Checks if the option is FUNCTION_DECLARATIONS. 47 * @method bool isLogprobs() Checks if the option is LOGPROBS. 48 * @method bool isMaxTokens() Checks if the option is MAX_TOKENS. 49 * @method bool isOutputFileType() Checks if the option is OUTPUT_FILE_TYPE. 50 * @method bool isOutputMediaAspectRatio() Checks if the option is OUTPUT_MEDIA_ASPECT_RATIO. 51 * @method bool isOutputMediaOrientation() Checks if the option is OUTPUT_MEDIA_ORIENTATION. 52 * @method bool isOutputMimeType() Checks if the option is OUTPUT_MIME_TYPE. 53 * @method bool isOutputModalities() Checks if the option is OUTPUT_MODALITIES. 54 * @method bool isOutputSchema() Checks if the option is OUTPUT_SCHEMA. 55 * @method bool isOutputSpeechVoice() Checks if the option is OUTPUT_SPEECH_VOICE. 56 * @method bool isPresencePenalty() Checks if the option is PRESENCE_PENALTY. 57 * @method bool isStopSequences() Checks if the option is STOP_SEQUENCES. 58 * @method bool isSystemInstruction() Checks if the option is SYSTEM_INSTRUCTION. 59 * @method bool isTemperature() Checks if the option is TEMPERATURE. 60 * @method bool isTopK() Checks if the option is TOP_K. 61 * @method bool isTopLogprobs() Checks if the option is TOP_LOGPROBS. 62 * @method bool isTopP() Checks if the option is TOP_P. 63 * @method bool isWebSearch() Checks if the option is WEB_SEARCH. 64 * 65 * @since 0.1.0 66 */ 67 class OptionEnum extends AbstractEnum 68 { 69 /** 70 * Input modalities option. 71 * 72 * This constant is not in ModelConfig as it's derived from message content, 73 * not configured directly. 74 */ 75 public const INPUT_MODALITIES = 'input_modalities'; 76 /** 77 * Determines the class enumerations by reflecting on class constants. 78 * 79 * Overrides the parent method to dynamically add constants from ModelConfig 80 * that are prefixed with KEY_. These are transformed to remove the KEY_ prefix 81 * and converted to snake_case values. 82 * 83 * @since 0.1.0 84 * 85 * @param class-string $className The fully qualified class name. 86 * @return array<string, string> The enum constants. 87 */ 88 protected static function determineClassEnumerations(string $className): array 89 { 90 // Start with the constants defined in this class using parent method 91 $constants = parent::determineClassEnumerations($className); 92 // Use reflection to get all constants from ModelConfig 93 $modelConfigReflection = new ReflectionClass(ModelConfig::class); 94 $modelConfigConstants = $modelConfigReflection->getConstants(); 95 // Add ModelConfig constants that start with KEY_ 96 foreach ($modelConfigConstants as $constantName => $constantValue) { 97 if (str_starts_with($constantName, 'KEY_')) { 98 // Remove KEY_ prefix to get the enum constant name 99 $enumConstantName = substr($constantName, 4); 100 // The value is the snake_case version stored in ModelConfig 101 // ModelConfig already stores these as snake_case strings 102 if (is_string($constantValue)) { 103 $constants[$enumConstantName] = $constantValue; 104 } 105 } 106 } 107 return $constants; 108 } 109 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sun Nov 1 08:20:35 2026 | Cross-referenced by PHPXref |