harden semantic match sby tags

This commit is contained in:
team2
2026-02-28 19:04:01 +01:00
parent ff01919b30
commit 1b5cff1c53
4 changed files with 134 additions and 56 deletions

View File

@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace App\Routing;
use App\Intent\SalesIntentLite;
/**
* IntentRouteResolver
*
* Deterministische Routing-Matrix für:
* Intent (SalesIntentLite)
* +
* erkannte Entity (CatalogIntentLite)
*
* Diese Klasse enthält KEINE Erkennungslogik.
* Sie entscheidet ausschließlich, welcher Modus gefahren wird.
*
* Erweiterbar über neue Intent-Konstanten.
*/
final class IntentRouteResolver
{
public const ROUTE_NORMAL = 'normal_rag';
public const ROUTE_CATALOG_LIST = 'catalog_list';
public const ROUTE_ENTITY_PRICING = 'entity_pricing';
public const ROUTE_ENTITY_COMPARISON = 'entity_comparison';
public const ROUTE_ENTITY_IMPLEMENTATION = 'entity_implementation';
public const ROUTE_ENTITY_ROI = 'entity_roi';
/**
* Routing-Entscheidung basierend auf Intent + Entity.
*
* @param string $intent Ergebnis aus SalesIntentLite
* @param string|null $entityLabel Ergebnis aus CatalogIntentLite
*/
public function resolve(string $intent, ?string $entityLabel): string
{
// ------------------------------------------------------------
// 1) Keine Entity → normales RAG
// ------------------------------------------------------------
if ($entityLabel === null || $entityLabel === '') {
return self::ROUTE_NORMAL;
}
// ------------------------------------------------------------
// 2) Intent-basierte Entscheidung
// ------------------------------------------------------------
return match ($intent) {
SalesIntentLite::DISCOVERY
=> self::ROUTE_CATALOG_LIST,
SalesIntentLite::PRICING
=> self::ROUTE_ENTITY_PRICING,
SalesIntentLite::COMPARISON
=> self::ROUTE_ENTITY_COMPARISON,
SalesIntentLite::IMPLEMENTATION
=> self::ROUTE_ENTITY_IMPLEMENTATION,
SalesIntentLite::ROI
=> self::ROUTE_ENTITY_ROI,
default
=> self::ROUTE_NORMAL,
};
}
}