AI Automator Token Replacement with removing unresolved Tokens (Checkbox?)
When we use the Advanced mode with Tokens in the AI Automator settings, Tokens which are not resolved by the Token system stay in the AI Prompt. This is not much text for AI, but everything what can be avoided to send to AI, should be removed.
As an example. I have an Entity where I defined a textarea called field_user_prompt which can optionally (!) be used to alter the prompt I setup in the field AI automation. So there is a Token like this: [node:field_user_prompt:value]. This stays when the user left the field empty. It's only replaced when something is filled in.
I do think that unresolved tokens have no benefit to a prompt which gets send to AI, so why not have a clean up anyways.
`
public function renderTokenPrompt($prompt, ContentEntityInterface $entity) {
// Get variables.
return $this->token->replace($prompt, [
$this->getEntityTokenType($entity->getEntityTypeId()) => $entity,
'user' => $this->currentUser,
]);
}
`
should be
`
public function renderTokenPrompt($prompt, ContentEntityInterface $entity) {
// Get variables.
return $this->token->replace($prompt, [
$this->getEntityTokenType($entity->getEntityTypeId()) => $entity,
'user' => $this->currentUser,
], ['clear' => TRUE]);
}
`
issue