optimize catalog semantic match sby tags
This commit is contained in:
@@ -15,6 +15,10 @@ use Symfony\Component\Uid\Uuid;
|
||||
* - TagVectorSearch (Score-Gate + Ambiguity-Check)
|
||||
* - DB Query auf document_tag + document (ACTIVE)
|
||||
* - Rückgabe als EIN Textblock (string) oder null (Fallback auf normalen Retrieval)
|
||||
*
|
||||
* Schritt-3 Änderung:
|
||||
* - Headline ist NICHT mehr hardcoded
|
||||
* - Headline basiert dynamisch auf dem gefundenen Tag
|
||||
*/
|
||||
final class EntityCatalogService
|
||||
{
|
||||
@@ -63,6 +67,10 @@ final class EntityCatalogService
|
||||
return null;
|
||||
}
|
||||
|
||||
// OPTIONAL: Falls TagVectorSearchClient künftig tag_label zurückliefert,
|
||||
// kann das hier direkt verwendet werden.
|
||||
$tagLabel = isset($best['tag_label']) ? (string)$best['tag_label'] : null;
|
||||
|
||||
// 3) DB Query: alle ACTIVE Dokumente zu diesem Tag
|
||||
$rows = $this->connection->fetchAllAssociative(
|
||||
'
|
||||
@@ -95,18 +103,24 @@ final class EntityCatalogService
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->buildTextBlock($entityTerm, $titles);
|
||||
return $this->buildTextBlock($tagLabel, $titles);
|
||||
}
|
||||
|
||||
private function buildTextBlock(string $entityTerm, array $titles): string
|
||||
/**
|
||||
* Dynamische Headline:
|
||||
* - Wenn Tag-Label vorhanden → verwenden
|
||||
* - Sonst generischer Fallback
|
||||
*/
|
||||
private function buildTextBlock(?string $tagLabel, array $titles): string
|
||||
{
|
||||
$headline = match ($entityTerm) {
|
||||
'geräte' => 'Folgende Geräte sind verfügbar:',
|
||||
'indikatoren' => 'Folgende Indikatoren sind verfügbar:',
|
||||
'funktionen' => 'Folgende Funktionen sind verfügbar:',
|
||||
'zubehör' => 'Folgendes Zubehör ist verfügbar:',
|
||||
default => 'Folgende Einträge sind verfügbar:',
|
||||
};
|
||||
$headline = 'Folgende Einträge sind verfügbar:';
|
||||
|
||||
if (\is_string($tagLabel) && \trim($tagLabel) !== '') {
|
||||
$headline = sprintf(
|
||||
'Folgende %s sind verfügbar:',
|
||||
$tagLabel
|
||||
);
|
||||
}
|
||||
|
||||
$lines = [];
|
||||
foreach ($titles as $title) {
|
||||
|
||||
Reference in New Issue
Block a user