getSupportedCapabilities(); foreach ($capabilities as $capability) { if ($capability->isTextGeneration()) { return new NvidiaTextGenerationModel($modelMetadata, $providerMetadata); } if ($capability->isImageGeneration()) { return new NvidiaImageGenerationModel($modelMetadata, $providerMetadata); } } throw new RuntimeException( 'Unsupported model capabilities: ' . implode(', ', $capabilities) ); } /** * {@inheritDoc} * * @since 1.0.0 */ protected static function createProviderMetadata(): ProviderMetadata { $providerMetadataArgs = [ 'nvidia', 'NVIDIA', ProviderTypeEnum::cloud(), 'https://build.nvidia.com', RequestAuthenticationMethod::apiKey() ]; // Provider description support was added in 1.2.0. if (version_compare(AiClient::VERSION, '1.2.0', '>=')) { // For WordPress, we should translate the description. if (function_exists('__')) { // phpcs:ignore Generic.Files.LineLength.TooLong $providerMetadataArgs[] = __('Text generation with NVIDIA NIM models (Llama, Nemotron, Mistral, Qwen) and image generation with FLUX models.', 'ai-provider-for-nvidia'); } else { // phpcs:ignore Generic.Files.LineLength.TooLong -- Description literal, kept in sync with the translated string above. $providerMetadataArgs[] = 'Text generation with NVIDIA NIM models (Llama, Nemotron, Mistral, Qwen) and image generation with FLUX models.'; } } // Provider logoPath support was added in 1.3.0. if (version_compare(AiClient::VERSION, '1.3.0', '>=')) { $providerMetadataArgs[] = dirname(__DIR__, 2) . '/assets/images/nvidia.svg'; } return new ProviderMetadata(...$providerMetadataArgs); } /** * {@inheritDoc} * * @since 1.0.0 */ protected static function createProviderAvailability(): ProviderAvailabilityInterface { // Check valid API access by attempting to list models. return new ListModelsApiBasedProviderAvailability( static::modelMetadataDirectory() ); } /** * {@inheritDoc} * * @since 1.0.0 */ protected static function createModelMetadataDirectory(): ModelMetadataDirectoryInterface { return new NvidiaModelMetadataDirectory(); } }