Skip to content
Snippets Groups Projects
Commit b8025132 authored by Marcus Johansson's avatar Marcus Johansson
Browse files

Issue #3449252 by Marcus_Johansson, nicxvan: Add simple text fields

parent 00ee0b0d
No related branches found
No related tags found
No related merge requests found
Pipeline #180005 passed with warnings
<?php
namespace Drupal\ai_interpolator_openai;
use Drupal\ai_interpolator\PluginBaseClasses\SimpleTextChat;
use Drupal\ai_interpolator\PluginInterfaces\AiInterpolatorFieldRuleInterface;
use Drupal\ai_interpolator_openai\OpenAiTrait;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
/**
* Helper for text bases.
*/
class OpenAiSimpleTextBase extends SimpleTextChat implements AiInterpolatorFieldRuleInterface {
use OpenAiTrait;
/**
* {@inheritDoc}
*/
public $title = 'OpenAI Simple Text';
/**
* {@inheritDoc}
*/
public function extraAdvancedFormFields(ContentEntityInterface $entity, FieldDefinitionInterface $fieldDefinition) {
$form = $this->loadExtraAdvancedFormFields($entity, $fieldDefinition);
return $form;
}
}
<?php
namespace Drupal\ai_interpolator_openai\Plugin\AiInterPolatorFieldRules;
use Drupal\ai_interpolator\PluginInterfaces\AiInterpolatorFieldRuleInterface;
use Drupal\ai_interpolator_openai\OpenAiSimpleTextBase;
/**
* The rules for a string field.
*
* @AiInterpolatorFieldRule(
* id = "ai_interpolator_openai_simple_string",
* title = @Translation("OpenAI Simple Text"),
* field_rule = "string"
* )
*/
class OpenAiSimpleString extends OpenAiSimpleTextBase implements AiInterpolatorFieldRuleInterface {
/**
* {@inheritDoc}
*/
public function placeholderText() {
return "Based on the context text create a summary under {{ max_length }} characters.\n\nContext:\n{{ context }}";
}
}
<?php
namespace Drupal\ai_interpolator_openai\Plugin\AiInterPolatorFieldRules;
use Drupal\ai_interpolator\PluginInterfaces\AiInterpolatorFieldRuleInterface;
use Drupal\ai_interpolator_openai\OpenAiSimpleTextBase;
/**
* The rules for a string_long field.
*
* @AiInterpolatorFieldRule(
* id = "ai_interpolator_openai_simple_string_long",
* title = @Translation("OpenAI Simple Text"),
* field_rule = "string_long"
* )
*/
class OpenAiSimpleStringLong extends OpenAiSimpleTextBase implements AiInterpolatorFieldRuleInterface {
/**
* {@inheritDoc}
*/
public function placeholderText() {
return "Based on the context text create a summary under {{ max_length }} characters.\n\nContext:\n{{ context }}";
}
}
<?php
namespace Drupal\ai_interpolator_openai\Plugin\AiInterPolatorFieldRules;
use Drupal\ai_interpolator\PluginInterfaces\AiInterpolatorFieldRuleInterface;
use Drupal\ai_interpolator_openai\OpenAiSimpleTextBase;
/**
* The rules for a text field.
*
* @AiInterpolatorFieldRule(
* id = "ai_interpolator_openai_simple_text",
* title = @Translation("OpenAI Simple Text"),
* field_rule = "text"
* )
*/
class OpenAiSimpleText extends OpenAiSimpleTextBase implements AiInterpolatorFieldRuleInterface {
/**
* {@inheritDoc}
*/
public function placeholderText() {
return "Based on the context text create a summary under {{ max_length }} characters.\n\nContext:\n{{ context }}";
}
}
<?php
namespace Drupal\ai_interpolator_openai\Plugin\AiInterPolatorFieldRules;
use Drupal\ai_interpolator\PluginInterfaces\AiInterpolatorFieldRuleInterface;
use Drupal\ai_interpolator_openai\OpenAiSimpleTextBase;
/**
* The rules for a text_long field.
*
* @AiInterpolatorFieldRule(
* id = "ai_interpolator_openai_simple_text_long",
* title = @Translation("OpenAI Simple Text"),
* field_rule = "text_long"
* )
*/
class OpenAiSimpleTextLong extends OpenAiSimpleTextBase implements AiInterpolatorFieldRuleInterface {
/**
* {@inheritDoc}
*/
public function placeholderText() {
return "Based on the context text create a summary under {{ max_length }} characters.\n\nContext:\n{{ context }}";
}
}
<?php
namespace Drupal\ai_interpolator_openai\Plugin\AiInterPolatorFieldRules;
use Drupal\ai_interpolator\PluginInterfaces\AiInterpolatorFieldRuleInterface;
use Drupal\ai_interpolator_openai\OpenAiSimpleTextBase;
/**
* The rules for a text_long_with_summary field.
*
* @AiInterpolatorFieldRule(
* id = "ai_interpolator_openai_simple_text_long_with_summary",
* title = @Translation("OpenAI Simple Text"),
* field_rule = "text_long_with_summary"
* )
*/
class OpenAiSimpleTextLongWithSummary extends OpenAiSimpleTextBase implements AiInterpolatorFieldRuleInterface {
/**
* {@inheritDoc}
*/
public function placeholderText() {
return "Based on the context text create a summary under {{ max_length }} characters.\n\nContext:\n{{ context }}";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment