harden semantic match sby tags
This commit is contained in:
70
src/Routing/IntentRouteResolver.php
Normal file
70
src/Routing/IntentRouteResolver.php
Normal 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,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user