PromptBuilder::inferCapabilityFromModelInterfaces( WordPressAiClientProvidersModelsContractsModelInterface $model ): WordPressAiClientProvidersModelsEnumsCapabilityEnum|null

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

Infers the capability from a model’s implemented interfaces.

Parameters

$modelWordPressAiClientProvidersModelsContractsModelInterfacerequired
The model to infer capability from.

Return

WordPressAiClientProvidersModelsEnumsCapabilityEnum|null The inferred capability, or null if none can be inferred.

Source

private function inferCapabilityFromModelInterfaces(ModelInterface $model): ?CapabilityEnum
{
    // Check model interfaces in order of preference
    if ($model instanceof TextGenerationModelInterface) {
        return CapabilityEnum::textGeneration();
    }
    if ($model instanceof ImageGenerationModelInterface) {
        return CapabilityEnum::imageGeneration();
    }
    if ($model instanceof TextToSpeechConversionModelInterface) {
        return CapabilityEnum::textToSpeechConversion();
    }
    if ($model instanceof SpeechGenerationModelInterface) {
        return CapabilityEnum::speechGeneration();
    }
    if ($model instanceof VideoGenerationModelInterface) {
        return CapabilityEnum::videoGeneration();
    }
    // No supported interface found
    return null;
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.