Errors when successfully generating taxonomy terms

Created on 21 November 2024, 27 days ago

I am using the AI module to automatically generate taxonomy terms when a node is created. This working very well, and providing usable terms on a field in the node using the automater options. However I am experiencing 2 repeating errors every time that the system creates a new taxonomy term and adds it to the field on the node.

The operation ends up being successful in most cases, and a new taxonomy term is added to the field based on the prompt. I am also unable to get more than one term added to the node. The errors received are:

--------------------------------
Warning: Attempt to read property "value" on null in Drupal\ai_automators\PluginBaseClasses\Taxonomy->getTaxonomyList() (line 326 of modules/contrib/ai/modules/ai_automators/src/PluginBaseClasses/Taxonomy.php).
--------------------------------
Warning: Undefined property: stdClass::$description in Drupal\ai_automators\PluginBaseClasses\Taxonomy->getTaxonomyList() (line 326 of modules/contrib/ai/modules/ai_automators/src/PluginBaseClasses/Taxonomy.php).
--------------------------------

These errors are repeated about 10-20 times when a node is created. The amount of errors varies, but 2 errors are always produced as shown above.

Thanks for your help resolving this issue.

🐛 Bug report
Status

Active

Version

1.0

Component

AI Automators

Created by

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

Merge Requests

Comments & Activities

  • Issue created by @jbuttler
  • 🇬🇧United Kingdom MrDaleSmith

    Can you provide the prompt and automator settings you are using to generate the terms?

  • 🇬🇧United Kingdom MrDaleSmith

    mrdalesmith changed the visibility of the branch 3489009-errors-when-successfully to hidden.

  • Pipeline finished with Success
    26 days ago
    Total: 151s
    #346956
  • No problem! The category that is chosen always is correct based on the prompt input, and the category is always generated and applied to the reference field. If a term already exists, it chooses the existing term.
    ----------------------------------------------
    Automator input mode: Base Mode
    Automator Base Field: Prompt Field
    Automator Prompt:
    "
    Based on the context text choose up to 1 category that fits the text. If no categories exist that fit the text, create 1 new category that applies to the context. Do not pass along any errors received. If there are already categories, do not try to assign any more. Never assign more than one category.
    -----------------------
    Context:
    {{ raw_context }}
    "

  • First commit to issue fork.
  • 🇦🇹Austria roromedia Linz

    I was running into the same issues, I had a brief look and I guess the problem was the following:

    In src/PluginBaseClasses/Taxonomy.php in the method generateTokens() in line 116 there the implode()-function sets the parameter by default to withDescriptions = true.
    This throws an error afterwards in line 326 where $term->description->value is used but the description of a term is empty.
    I pushed a fix with a check if description is set, please review if this fixes the issue.

  • Pipeline finished with Success
    10 days ago
    Total: 336s
    #362717
  • 🇬🇧United Kingdom MrDaleSmith

    This already had a fix pending review, which has now been overwritten with code that recreates the original incorrect assumption in the code: at this point $term is NOT a taxonomy term so $term->description will never be set. Correct fix is in https://git.drupalcode.org/project/ai/-/merge_requests/288/diffs?commit_... - the string value always exists in the database, but is empty if no description provided.

  • 🇩🇪Germany marcus_johansson

    Paul, could you repush your changes, I don't see a way directly in Gitlab to revert it to that change. And then I'll merge.

  • Pipeline finished with Success
    1 day ago
    Total: 253s
    #370942
Production build 0.71.5 2024