From 89dae1241c84172c6f07a7d1a8b86ceb383982c4 Mon Sep 17 00:00:00 2001 From: Simon Schmidt Date: Tue, 31 Mar 2026 11:53:38 +0200 Subject: [PATCH] [BUGFIX] fixed getting unwanted fields from LLM --- .../Domain/Repository/Llm/AbstractRepository.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Classes/Domain/Repository/Llm/AbstractRepository.php b/Classes/Domain/Repository/Llm/AbstractRepository.php index 967cca3..a6990a8 100644 --- a/Classes/Domain/Repository/Llm/AbstractRepository.php +++ b/Classes/Domain/Repository/Llm/AbstractRepository.php @@ -28,10 +28,21 @@ protected function getPrompt(array $languageCodes): string $prompt .= 'Required languages: ' . implode(', ', $languageCodes) . '. '; $prompt .= 'Each language must have keys: ' . $this->getFieldKeys() . '. '; $prompt .= 'Return ONLY a valid JSON object, no markdown, no code blocks, no explanation. '; - $prompt .= 'Format: {"en": {"title": "...", "description": "...", "alternativeText": "..."}, "de": {...}}'; + $prompt .= 'Format: ' . $this->getFormat($languageCodes, array_keys($this->getFields())); return $prompt; } + protected function getFormat(array $languageCodes, array $fields): string + { + $format = []; + foreach ($languageCodes as $languageCode) { + foreach ($fields as $field) { + $format[$languageCode][$field] = '...'; + } + } + return json_encode($format, JSON_UNESCAPED_UNICODE); + } + protected function getPromptPrefix(): string { $content = '';