fix retrieve final technical questions

This commit is contained in:
team 1
2026-04-24 11:32:54 +02:00
parent b800c1fc8f
commit 8a7cb89c5d
3 changed files with 190 additions and 7 deletions

View File

@@ -40,6 +40,14 @@ final class CommerceIntentLite
);
}
if ($this->isTechnicalFactualKnowledgeQuery($prompt) && !$this->hasExplicitCommerceIntent($prompt)) {
return $this->buildDetectionResult(
intent: self::NONE,
score: 0,
signals: ['technical_factual_knowledge_query']
);
}
$score = 0;
$signals = [];
@@ -87,6 +95,49 @@ final class CommerceIntentLite
return $this->matchesAnyPattern($prompt, $this->config->getExplicitCommerceIntentPatterns());
}
/**
* Detects factual technical knowledge questions that must stay in RAG retrieval.
*
* Product names such as Testomat can look like commerce queries, but questions
* about limits, measuring ranges, thresholds, resolution or monitoring values
* must not trigger shop search. Shop search may still run when the user uses
* explicit commerce wording such as price, buy, order, shop, article or SKU.
*/
private function isTechnicalFactualKnowledgeQuery(string $prompt): bool
{
$hasQuestionMarker = $this->matchesAnyPattern($prompt, [
'/\bwas\s+ist\b/u',
'/\bwelche?r?s?\b/u',
'/\bwie\s+(hoch|niedrig|klein|gross|groß)\b/u',
'/\bniedrigste[rsn]?\b/u',
'/\bkleinste[rsn]?\b/u',
'/\bhöchste[rsn]?\b/u',
'/\bhoechste[rsn]?\b/u',
]);
if (!$hasQuestionMarker) {
return false;
}
return $this->matchesAnyPattern($prompt, [
'/\bgrenzwert(?:e|en|es)?\b/u',
'/\bmessbereich(?:e|en|s)?\b/u',
'/\bwasserhärte\b/u',
'/\bwasserhaerte\b/u',
'/\bresthärte\b/u',
'/\bresthaerte\b/u',
'/\bgesamthärte\b/u',
'/\bgesamthaerte\b/u',
'/\bauflösung\b/u',
'/\baufloesung\b/u',
'/\bindikator(?:en|s)?\b/u',
'/\btestomat(?:en|s)?\b/u',
'/\büberwach(?:t|en|ung)\b/u',
'/\bueberwach(?:t|en|ung)\b/u',
'/\bmess(?:en|ung|bar|wert)\b/u',
]);
}
/**
* @param string[] $patterns
*/