registry = $registry;
}
/**
* Renders the widget content.
*
* Shows Ability statistics and per-provider capabilities.
*
* @since 0.8.0
*/
public function render(): void {
?>
render_abilities_summary(); ?>
render_provider_capabilities(); ?>
registry->get_feature( 'abilities-explorer' );
if ( $feature && $feature->is_enabled() ) :
?>
getRegisteredProviderIds();
if ( empty( $provider_ids ) ) {
return;
}
$providers = array();
foreach ( $provider_ids as $provider_id ) {
try {
$provider_class = $registry->getProviderClassName( $provider_id );
/** @var \WordPress\AiClient\Providers\Contracts\ProviderInterface $provider_class */
$metadata = $provider_class::metadata();
$model_dir = $provider_class::modelMetadataDirectory();
$models = $model_dir->listModelMetadata();
$capabilities = array();
foreach ( $models as $model ) {
foreach ( $model->getSupportedCapabilities() as $capability ) {
$capabilities[ $capability->value ] = true;
}
}
if ( empty( $capabilities ) ) {
continue;
}
$providers[] = array(
'name' => $metadata->getName(),
'capabilities' => $capabilities,
);
} catch ( \Throwable $e ) {
continue;
}
}
if ( empty( $providers ) ) {
return;
}
?>
$unused ) : ?>
get_capability_label( (string) $cap_value ) ); ?>
__( 'Text Generation', 'ai' ),
CapabilityEnum::IMAGE_GENERATION => __( 'Image Generation', 'ai' ),
CapabilityEnum::TEXT_TO_SPEECH_CONVERSION => __( 'Text to Speech', 'ai' ),
CapabilityEnum::SPEECH_GENERATION => __( 'Speech Generation', 'ai' ),
CapabilityEnum::MUSIC_GENERATION => __( 'Music Generation', 'ai' ),
CapabilityEnum::VIDEO_GENERATION => __( 'Video Generation', 'ai' ),
CapabilityEnum::EMBEDDING_GENERATION => __( 'Embedding Generation', 'ai' ),
CapabilityEnum::CHAT_HISTORY => __( 'Chat History', 'ai' ),
);
return $labels[ $capability ] ?? $capability;
}
}