diff --git a/src/Services/InfoProviderSystem/Providers/AIInfoExtractor.php b/src/Services/InfoProviderSystem/Providers/AIInfoExtractor.php
index 92ed4e19..2032f634 100644
--- a/src/Services/InfoProviderSystem/Providers/AIInfoExtractor.php
+++ b/src/Services/InfoProviderSystem/Providers/AIInfoExtractor.php
@@ -35,6 +35,7 @@ use League\HTMLToMarkdown\HtmlConverter;
use Symfony\AI\Platform\Message\Message;
use Symfony\AI\Platform\Message\MessageBag;
use Symfony\Component\DomCrawler\Crawler;
+use Symfony\Component\Intl\Languages;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use function Symfony\Component\String\u;
@@ -210,7 +211,7 @@ final class AIInfoExtractor implements InfoProviderInterface
private function buildSystemPrompt(): string
{
- return <<<'PROMPT'
+ $tmp = <<<'PROMPT'
You are an expert at extracting electronic component information from web pages. Extract structured data in JSON format, from markdown extracted from a product page.
Focus on the main content of the page, such as product descriptions, specifications, and tables. Ignore navigation menus, footers, and sidebars.
@@ -224,6 +225,14 @@ Rules:
For parameters, combine name, value, and unit. The unit should be separate if possible.
PROMPT;
+
+ if ($this->settings->outputLanguage === null) {
+ $tmp .= "\n\nProvide the response in the same language of the webpage.";
+ } else {
+ $tmp .= "\n\nThe response must be in ". Languages::getName($this->settings->outputLanguage, 'en') ." language. Translate texts if needed.";
+ }
+
+ return $tmp;
}
}
diff --git a/src/Settings/InfoProviderSystem/AIExtractorSettings.php b/src/Settings/InfoProviderSystem/AIExtractorSettings.php
index 876c687f..4ef9a1fa 100644
--- a/src/Settings/InfoProviderSystem/AIExtractorSettings.php
+++ b/src/Settings/InfoProviderSystem/AIExtractorSettings.php
@@ -32,7 +32,9 @@ use Jbtronics\SettingsBundle\Settings\Settings;
use Jbtronics\SettingsBundle\Settings\SettingsParameter;
use Jbtronics\SettingsBundle\Settings\SettingsTrait;
use Symfony\AI\Platform\Capability;
+use Symfony\Component\Form\Extension\Core\Type\LanguageType;
use Symfony\Component\Translation\TranslatableMessage as TM;
+use Symfony\Component\Validator\Constraints\Language;
#[Settings(name: "ai_extractor", label: new TM("settings.ips.ai_extractor"), description: new TM("settings.ips.ai_extractor.description"))]
#[SettingsIcon("fa-plug")]
@@ -56,4 +58,10 @@ class AIExtractorSettings
description: new TM("settings.ips.ai_extractor.max_content_length.description"),
)]
public int $maxContentLength = 50000;
+
+ #[Language]
+ #[SettingsParameter(label: new TM("settings.ips.ai_extractor.output_language"), description: new TM("settings.ips.ai_extractor.output_language.description"),
+ formType: LanguageType::class,
+ )]
+ public ?string $outputLanguage = null;
}
diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf
index e16a6d69..c0bf8b60 100644
--- a/translations/messages.en.xlf
+++ b/translations/messages.en.xlf
@@ -13103,5 +13103,29 @@ Buerklin-API Authentication server:
The AI model that should be used for extraction. Must support structured output.
+
+
+ settings.ips.ai_extractor.max_content_length
+ Max. Website Content length
+
+
+
+
+ settings.ips.ai_extractor.max_content_length.description
+ The maximum number of characters of the website that are sent to the AI service.
+
+
+
+
+ settings.ips.ai_extractor.output_language
+ Output language
+
+
+
+
+ settings.ips.ai_extractor.output_language.description
+ By default, the providers returns information in the same language as the website. With that option you can ask the AI to translate it for you. Might only work with certain models.
+
+