Can real tokens be used in AI Prompt values?

Created on 6 August 2025, about 2 months ago

Problem/Motivation

AI Prompt Types allow you to create custom variables or tokens to save with them for usage, but it does not appear that you can use actual Drupal tokens in either the prompt type form or the prompt itself (does not seem to replace normal Drupal tokens). It would probably be beneficial if they did.

One case I ran into was I had a prompt where I wanted to ask AI to select appropriate terms from a list of 200 terms, so I am passing that tree as a JSON object. Which means somewhere within my custom code, I am doing:

      $taxonomy_prompt = \Drupal::config('ai.ai_prompt.assign_taxonomy')->get('prompt');
      $taxonomy_prompt = \Drupal::service('token')->replace($taxonomy_prompt);

is there a reason the prompt is not run through token replacement anyway? Or is there a service I didn't notice that prepares the prompt for it?

πŸ’¬ Support request
Status

Active

Version

1.2

Component

...to be triaged

Created by

πŸ‡ΊπŸ‡ΈUnited States kevinquillen

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

Comments & Activities

Production build 0.71.5 2024