add new configs

This commit is contained in:
team 1
2026-04-15 08:46:26 +02:00
parent 8cac77ed31
commit 1815a42035
18 changed files with 508 additions and 309 deletions

View File

@@ -4,19 +4,27 @@ declare(strict_types=1);
namespace App\Intent;
use App\Config\IntentLightConfig;
/**
* IntentLite
*
* Deterministische, LLM-agnostische Intent-Erkennung.
* Fokus: LIST-Intent für Retrieval-Steuerung.
* Deterministic, LLM-agnostic intent detection.
* Focus: LIST intent for retrieval control.
*
* WICHTIG:
* - Immer mit dem ORIGINAL-Prompt aufrufen.
* - Nicht mit dem QueryCleaner-Ergebnis.
* IMPORTANT:
* - Always call it with the ORIGINAL prompt.
* - Not with the QueryCleaner result.
*/
final class IntentLite
final readonly class IntentLite
{
private const LIST_THRESHOLD = 4;
public function __construct(
private IntentLightConfig $config
)
{
}
public function detectList(string $originalPrompt): array
{
@@ -28,19 +36,7 @@ final class IntentLite
// --------------------------------------------------------
// 1. Starke explizite Listen-Trigger (hohes Gewicht)
// --------------------------------------------------------
$strongPatterns = [
'/\bliste(n)?\b/u',
'/\bauflisten\b/u',
'/\baufz(a|ä)hl(en)?\b/u',
'/\bnenn(e)?\b/u',
'/\bzeig(e)?\b/u',
'/\bwelche\s+sind\b/u',
'/\bwelche\s+gibt\s+es\b/u',
'/\bwas\s+sind\b/u',
'/\bwie\s+viele\b/u',
'/\branking\b/u',
'/\btop\s*\d+\b/u',
];
$strongPatterns = $this->config->getStrongPatterns();
foreach ($strongPatterns as $pattern) {
if (preg_match($pattern, $p) === 1) {
@@ -52,27 +48,7 @@ final class IntentLite
// --------------------------------------------------------
// 2. Mengen- / Mehrzahl-Indikatoren
// --------------------------------------------------------
$quantityWords = [
'alle',
'sämtliche',
'saemtliche',
'mehrere',
'verschiedene',
'einige',
'viele',
'optionen',
'möglichkeiten',
'moeglichkeiten',
'varianten',
'arten',
'modelle',
'funktionen',
'punkte',
'schritte',
'kategorien',
'übersicht',
'uebersicht',
];
$quantityWords = $this->config->getQuantityWords();
foreach ($quantityWords as $word) {
if (preg_match('/\b' . preg_quote($word, '/') . '\b/u', $p) === 1) {
@@ -102,11 +78,11 @@ final class IntentLite
// --------------------------------------------------------
// Entscheidung
// --------------------------------------------------------
$isList = $score >= self::LIST_THRESHOLD;
$isList = $score >= IntentLightConfig::LIST_THRESHOLD;
return [
'is_list' => $isList,
'score' => $score,
'score' => $score,
'signals' => $signals,
];
}