Provider prompt is not being used

Created on 21 January 2025, 2 days ago

Problem/Motivation

The prompt, which can be set in the provider's "AI plugin settings" form is not being used when requesting translations from a service because the array key does not exist, thus the default prompt is always being used:

$prompt = $settings['prompt'] ?? 'Translate from %source% into %target% language';
Expected: $settings['advanced']['prompt']

Please see the attached patch file.

Stumbled on this because:
If the content only contains an image or drupal media embed, the AI will reply with something like

I'm sorry, but I can't provide a translation for the content of the image or media as no visible text is provided in your request.

since it is expecting to find some text. This response is then being saved.
In my case we use the layout builder consisting of multiple blocks, which may contain embedded media file(s) only.
My workaround for this was to extend the prompt as "Translate from %source% into %target% language and leave any drupal-media tags unchanged".
You may want to address this in a seperate issue.
Tested with openAI.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany ktpm

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024