- Issue created by @jhedstrom
- ๐ฎ๐ณIndia prashant.c Dharamshala
prashant.c โ made their first commit to this issueโs fork.
- Merge request !621Added Placeholders available section for advanced mode โ (Open) created by prashant.c
- ๐ฎ๐ณIndia prashant.c Dharamshala
Added the code to have the "Placeholders available" section for the Advanced mode. Needs to be reviewed.
- ๐ฎ๐ณIndia Kanchan Bhogade
Hi
Tested MR 621 on Drupal 11.x
The Mr is applied successfully...Testing Steps:
1. Install AI Module
2. Install the AI Automators module with the Token Module
3. Enabled the AI Autometers on the entity type's field
4. Select AI Automatos settings > Automator Input Mode > Advanced Mode (token)
5. Check for the PlaceholderResult:
The Placeholder is available when using advanced (token) mode.Attaching screenshots for reference
- ๐บ๐ธUnited States jhedstrom Portland, OR
These now appear on the form to configure the automator, however they are not actually replaced in the plugin (
RuleBase::generate()
) as this code doesn't fire for the advanced configuration:public function generate(ContentEntityInterface $entity, FieldDefinitionInterface $fieldDefinition, array $automatorConfig) { // Generate the real prompt if needed. $prompts = []; // @phpstan-ignore-next-line if (!empty($automatorConfig['mode']) && $automatorConfig['mode'] == 'token' && \Drupal::service('module_handler')->moduleExists('token')) { $prompts[] = \Drupal::service('ai_automator.prompt_helper')->renderTokenPrompt($automatorConfig['token'], $entity); /* @phpstan-ignore-line */ } elseif ($this->needsPrompt()) { // Run rule. foreach ($entity->get($automatorConfig['base_field'])->getValue() as $i => $item) { // Get tokens. $tokens = $this->generateTokens($entity, $fieldDefinition, $automatorConfig, $i); $prompts[] = \Drupal::service('ai_automator.prompt_helper')->renderPrompt($automatorConfig['prompt'], $tokens, $i); /* @phpstan-ignore-line */ } } return $prompts; }
- ๐ฎ๐ณIndia prashant.c Dharamshala
I think it would be better if Marcus could confirm whether the placeholders not implemented for advanced mode are done on purpose or missed.
- ๐บ๐ธUnited States jhedstrom Portland, OR
If they are intentionally left out, are there examples of how to replicate the prompt available at the Base level? I'm not aware of a token that would provide, for example, all the taxonomy terms available to a given field...
- ๐บ๐ธUnited States jhedstrom Portland, OR
I updated the PR and am adding a patch for use with composer here.