<?php

declare(strict_types=1);

namespace Drupal\ai\Plugin\AiPlatform;

use Drupal\ai\Attribute\AiPlatform;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Symfony\AI\Platform\Bridge\Gemini\ModelCatalog;
use Symfony\AI\Platform\Bridge\Gemini\PlatformFactory;
use Symfony\AI\Platform\ModelCatalog\ModelCatalogInterface;
use Symfony\AI\Platform\PlatformInterface;

/**
 * Plugin implementation of the "Gemini" AI provider.
 *
 * @todo Move this implementation to the 'gemini_provider' module before release.
 */
#[AiPlatform(
  id: 'gemini',
  label: new TranslatableMarkup('Gemini'),
  description: new TranslatableMarkup("Gemini models hosted on Google's platform"),
)]
final class Gemini extends AiPlatformUsingApiKeyAuthenticationPluginBase {

  /**
   * {@inheritdoc}
   */
  protected function initializePlatform(): PlatformInterface {
    return PlatformFactory::create(
      apiKey: $this->getApiKey() ?? '',
      httpClient: $this->httpClient,
      modelCatalog: $this->getModelCatalog(),
      eventDispatcher: $this->eventDispatcher,
    );
  }

  /**
   * {@inheritdoc}
   */
  public function getModelCatalog(): ModelCatalogInterface {
    return new ModelCatalog();
  }

  /**
   * {@inheritdoc}
   */
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state): void {
  }

  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state): void {
  }

}
