Can real tokens be used in AI Prompt values?
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3539991. -->
Reported by: [kevinquillen](https://www.drupal.org/user/317279)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>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.</p>
<p>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:</p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br> $taxonomy_prompt </span><span style="color: #007700">= \</span><span style="color: #0000BB">Drupal</span><span style="color: #007700">::</span><span style="color: #0000BB">config</span><span style="color: #007700">(</span><span style="color: #DD0000">'ai.ai_prompt.assign_taxonomy'</span><span style="color: #007700">)-></span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">'prompt'</span><span style="color: #007700">);<br> </span><span style="color: #0000BB">$taxonomy_prompt </span><span style="color: #007700">= \</span><span style="color: #0000BB">Drupal</span><span style="color: #007700">::</span><span style="color: #0000BB">service</span><span style="color: #007700">(</span><span style="color: #DD0000">'token'</span><span style="color: #007700">)-></span><span style="color: #0000BB">replace</span><span style="color: #007700">(</span><span style="color: #0000BB">$taxonomy_prompt</span><span style="color: #007700">);<br></span><span style="color: #0000BB">?></span></span></pre></div>
<p>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?</p>
issue