If the entity-reference field in the content type allows references to more than one other content type, the prompt sent to AI with have "Array" instead of the actual entity name.

In GetAISuggestions, there is this code:

      $possible_results = $this->getFieldAllowedValues($node, $field_name);
      $imploded_possible_results = implode('|', $possible_results);

When the field allows multiple content types, the $possible_results is a nested array rather that a simple array. For example:

$possible_results = [
  "article" = [
    1 = "article 1",
    2 = "article 2",
    ].
    "event" = [
    1 = "event 1",
    2 = "event 2",
    ]
  ]

which ends up with $imploded_possible_results being "Array|Array"

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mpotter created an issue. See original summary.

scott_euser made their first commit to this issue’s fork.

  • scott_euser committed 77db5e6b on 1.0.x
    Issue #3506821 by scott_euser, mpotter: Problem when referencing...
scott_euser’s picture

Status: Active » Fixed

Thanks for spotting and for finding the root cause!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.