second step
This commit is contained in:
@@ -21,11 +21,10 @@ use Symfony\Component\Uid\Uuid;
|
||||
*/
|
||||
final class EntityCatalogService
|
||||
{
|
||||
private const SEARCH_LIMIT = 3;
|
||||
|
||||
public function __construct(
|
||||
private readonly TagVectorSearchClient $tagVectorClient,
|
||||
private readonly Connection $connection,
|
||||
private readonly CatalogIntentConfig $config,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -40,7 +39,7 @@ final class EntityCatalogService
|
||||
return null;
|
||||
}
|
||||
|
||||
$hits = $this->tagVectorClient->search($entityTerm, self::SEARCH_LIMIT);
|
||||
$hits = $this->tagVectorClient->search($entityTerm, $this->config->getListSearchLimit());
|
||||
|
||||
if ($hits === []) {
|
||||
return null;
|
||||
@@ -49,7 +48,7 @@ final class EntityCatalogService
|
||||
$best = $hits[0];
|
||||
$bestScore = (float) ($best['score'] ?? 0.0);
|
||||
|
||||
if ($bestScore < CatalogIntentConfig::MIN_SCORE) {
|
||||
if (!$this->config->isScoreAccepted($bestScore)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -60,7 +59,7 @@ final class EntityCatalogService
|
||||
if (isset($hits[1])) {
|
||||
$secondScore = (float) ($hits[1]['score'] ?? 0.0);
|
||||
|
||||
if (abs($bestScore - $secondScore) < CatalogIntentConfig::AMBIGUITY_DELTA) {
|
||||
if ($this->config->isAmbiguous($bestScore, $secondScore)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user