ai_agents_test-1.0.0-alpha1/src/Plugin/AgentsParameterTest/NotEqualsTest.php

src/Plugin/AgentsParameterTest/NotEqualsTest.php
<?php

declare(strict_types=1);

namespace Drupal\ai_agents_test\Plugin\AgentsParameterTest;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\ai\Service\FunctionCalling\ExecutableFunctionCallInterface;
use Drupal\ai_agents_test\AgentsParameterTestPluginBase;
use Drupal\ai_agents_test\Attribute\AgentsParameterTest;

/**
 * Plugin implementation of the agents_parameter_test.
 */
#[AgentsParameterTest(
  id: 'not_equals',
  label: new TranslatableMarkup('Not Equals'),
  description: new TranslatableMarkup('Is exactly not the same.'),
)]
final class NotEqualsTest extends AgentsParameterTestPluginBase {

  /**
   * {@inheritdoc}
   */
  public function runTest(ExecutableFunctionCallInterface $tool, array $values, string $parameter_name, array $rule, string $tool_name): void {
    $actual = (string) $values[$parameter_name];
    if ($actual === $rule['value']) {
      $this->errors[] = sprintf('Parameter %s for tool %s was not equal to %s.', $parameter_name, $tool->getToolsId(), $rule['value']);
      $this->details[] = $this->createDetailedResultRow(
        result: FALSE,
        object: "Tool: $tool_name, Parameter: $parameter_name",
        type: 'Equals',
        expected: $rule['value'],
        actual: $actual,
        details: sprintf('Parameter %s for tool %s was not equal to %s.', $parameter_name, $tool->getToolsId(), $rule['value'])
      );
    }
    else {
      $this->details[] = $this->createDetailedResultRow(
        result: TRUE,
        object: "Tool: $tool_name, Parameter: $parameter_name",
        type: 'Equals',
        expected: $rule['value'],
        actual: $actual,
        details: '',
      );
    }
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc