AI Automator Taxonomy - Advanced (token) mode doesn't work with edit_mode

Created on 18 October 2024, about 1 month ago

Problem/Motivation

I want to use edit mode when in advanced mode for taxonomy selection.

Steps to reproduce

In advanced mode set edit mode to true, and save a node which already has a value for the target field. Upon saving the value isn't updated

Proposed resolution

in AiAutomatorEntityModifier::tokenShouldSave add a check for edit_mode before returning false


  /**
   * If token mode, check if it should run.
   */
  private function tokenShouldSave(ContentEntityInterface $entity, array $automatorConfig) {

    // Get rule.
    $rule = $this->fieldRules->findRule($automatorConfig['rule']);

    // Check if a value exists.
    $value = $entity->get($automatorConfig['field_name'])->getValue();
    $value = $rule->checkIfEmpty($value);

    // If the value is already set, and is edit mode false, then nothing to do
    if (!empty($value) && !empty($value[0]) && !$automatorConfig['edit_mode']) {
      return FALSE;
    }
    return TRUE;
  }

Feature request
Status

Needs review

Version

1.0

Component

AI Automators

Created by

🇬🇧United Kingdom jonnyToomey

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jonnyToomey
  • 🇩🇪Germany marcus_johansson

    Ah, maybe we need to update the explanation there - this only works in base mode and only works when you change something in the base field the taxonomy is based on.

    The idea is for instance if you have a body field that you want to check if its ok that it gets published and it approves it and then someone goes in and changes the body field it should still do a check even if the value is filled out.

    So the code changes suggested, would not really work for what you are trying to achieve.

    If we were to allow resaving on every edit, people would get angry and wonder why their bills rack up and why the content changes all the time, even when something triggers it like a comment count update or something.

    If you are looking for a solution where it will run every time, even if its filled in, you could at the moment create an ECA workflow and use the AI ECA to trigger it.

    The second thing that is in the pipeline is a widget systems around the AI Automators module, where you will be able to trigger reruns already in the edit form.

    If you feel like this is answer enough, please close it. If you feel like there is a better UX to handle your use case, please describe that and we will try to make it happen.

  • 🇩🇪Germany marcus_johansson

    I guess in theory we could look what tokens exists in the prompt, try to check if any of them changed and then change based on this. But I think that would still not help your use case?

Production build 0.71.5 2024