central config part 1
This commit is contained in:
@@ -6,11 +6,74 @@ namespace App\Config;
|
||||
|
||||
final class PromptBuilderConfig
|
||||
{
|
||||
private const TECHNICAL_PRODUCT_KEYWORDS = [
|
||||
'technisch',
|
||||
'technical',
|
||||
'produkt',
|
||||
'product',
|
||||
'gerät',
|
||||
'device',
|
||||
'modell',
|
||||
'model',
|
||||
'messprinzip',
|
||||
'measurement principle',
|
||||
'schnittstelle',
|
||||
'interface',
|
||||
'relais',
|
||||
'relay',
|
||||
'indikator',
|
||||
'indicator',
|
||||
'grenzwert',
|
||||
'threshold',
|
||||
'messbereich',
|
||||
'measurement range',
|
||||
'minimaler',
|
||||
'minimum',
|
||||
'resthärte',
|
||||
'resthaerte',
|
||||
'°dh',
|
||||
'dh',
|
||||
'spannung',
|
||||
'voltage',
|
||||
'strom',
|
||||
'current',
|
||||
'druck',
|
||||
'pressure',
|
||||
'temperatur',
|
||||
'temperature',
|
||||
'schutzart',
|
||||
'ip',
|
||||
'fehlercode',
|
||||
'error code',
|
||||
'wasserhärte',
|
||||
'hardness',
|
||||
'testomat',
|
||||
'chlor',
|
||||
'chlormessung',
|
||||
];
|
||||
|
||||
private const ACCESSORY_REQUEST_KEYWORDS = [
|
||||
'passend',
|
||||
'passende',
|
||||
'passendes',
|
||||
'zubehör',
|
||||
'zubehor',
|
||||
'dazu',
|
||||
'indikator',
|
||||
'reagenz',
|
||||
'kit',
|
||||
'set',
|
||||
'zusatz',
|
||||
'ergänzung',
|
||||
'ergaenzung',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly array $config = [],
|
||||
private readonly ?DomainVocabularyConfig $vocabulary = null,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -88,6 +151,42 @@ final class PromptBuilderConfig
|
||||
return is_numeric($value) ? (float) $value : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function getStringList(string $path, array $default): array
|
||||
{
|
||||
$value = $this->getValue($path, $default);
|
||||
|
||||
if (!is_array($value)) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
$out = [];
|
||||
foreach ($value as $item) {
|
||||
if (!is_scalar($item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = trim((string) $item);
|
||||
if ($item === '' || in_array($item, $out, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$out[] = $item;
|
||||
}
|
||||
|
||||
return $out !== [] ? $out : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function vocabularyView(string $path, array $fallback): array
|
||||
{
|
||||
return $this->vocabulary?->view($path, $fallback) ?? $fallback;
|
||||
}
|
||||
|
||||
private function getValue(string $path, mixed $default): mixed
|
||||
{
|
||||
$current = $this->config;
|
||||
@@ -445,51 +544,10 @@ final class PromptBuilderConfig
|
||||
*/
|
||||
public function getTechnicalProductKeywords(): array
|
||||
{
|
||||
return [
|
||||
'technisch',
|
||||
'technical',
|
||||
'produkt',
|
||||
'product',
|
||||
'gerät',
|
||||
'device',
|
||||
'modell',
|
||||
'model',
|
||||
'messprinzip',
|
||||
'measurement principle',
|
||||
'schnittstelle',
|
||||
'interface',
|
||||
'relais',
|
||||
'relay',
|
||||
'indikator',
|
||||
'indicator',
|
||||
'grenzwert',
|
||||
'threshold',
|
||||
'messbereich',
|
||||
'measurement range',
|
||||
'minimaler',
|
||||
'minimum',
|
||||
'resthärte',
|
||||
'resthaerte',
|
||||
'°dh',
|
||||
'dh',
|
||||
'spannung',
|
||||
'voltage',
|
||||
'strom',
|
||||
'current',
|
||||
'druck',
|
||||
'pressure',
|
||||
'temperatur',
|
||||
'temperature',
|
||||
'schutzart',
|
||||
'ip',
|
||||
'fehlercode',
|
||||
'error code',
|
||||
'wasserhärte',
|
||||
'hardness',
|
||||
'testomat',
|
||||
'chlor',
|
||||
'chlormessung',
|
||||
];
|
||||
return $this->getStringList(
|
||||
'technical_product_keywords',
|
||||
$this->vocabularyView('prompt.technical_product_keywords', self::TECHNICAL_PRODUCT_KEYWORDS)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -497,21 +555,10 @@ final class PromptBuilderConfig
|
||||
*/
|
||||
public function getAccessoryRequestKeywords(): array
|
||||
{
|
||||
return [
|
||||
'passend',
|
||||
'passende',
|
||||
'passendes',
|
||||
'zubehör',
|
||||
'zubehor',
|
||||
'dazu',
|
||||
'indikator',
|
||||
'reagenz',
|
||||
'kit',
|
||||
'set',
|
||||
'zusatz',
|
||||
'ergänzung',
|
||||
'ergaenzung',
|
||||
];
|
||||
return $this->getStringList(
|
||||
'accessory_request_keywords',
|
||||
$this->vocabularyView('prompt.accessory_request_keywords', self::ACCESSORY_REQUEST_KEYWORDS)
|
||||
);
|
||||
}
|
||||
|
||||
public function getTechnicalProductModelPattern(): string
|
||||
|
||||
Reference in New Issue
Block a user