p99c
This commit is contained in:
@@ -4155,7 +4155,6 @@ final readonly class AgentRunner
|
||||
$shopSearchQuery === ''
|
||||
|| trim($commerceHistoryContext) === ''
|
||||
|| $this->referenceAnchorExtractor->extractFirstProductModelAnchor($prompt) !== ''
|
||||
|| $this->referenceAnchorExtractor->extractFirstProductModelAnchor($shopSearchQuery) !== ''
|
||||
) {
|
||||
return $shopSearchQuery;
|
||||
}
|
||||
@@ -4164,10 +4163,6 @@ final readonly class AgentRunner
|
||||
return $shopSearchQuery;
|
||||
}
|
||||
|
||||
if (!$this->isGenericMainDeviceReferentialShopQuery($shopSearchQuery)) {
|
||||
return $shopSearchQuery;
|
||||
}
|
||||
|
||||
$modelAnchor = $this->normalizeShopQueryAnchor(
|
||||
$this->extractLatestHistoryProductModelAnchor($commerceHistoryContext)
|
||||
);
|
||||
@@ -4176,9 +4171,43 @@ final readonly class AgentRunner
|
||||
return $shopSearchQuery;
|
||||
}
|
||||
|
||||
return $this->queryAlreadyContainsAllAnchorTokens($shopSearchQuery, $modelAnchor)
|
||||
? $shopSearchQuery
|
||||
: $modelAnchor;
|
||||
if ($this->queryAlreadyContainsAllAnchorTokens($shopSearchQuery, $modelAnchor)) {
|
||||
return $this->containsMainDeviceFollowUpAccessoryResidual($shopSearchQuery, $modelAnchor)
|
||||
? $modelAnchor
|
||||
: $shopSearchQuery;
|
||||
}
|
||||
|
||||
if (!$this->isGenericMainDeviceReferentialShopQuery($shopSearchQuery)) {
|
||||
return $shopSearchQuery;
|
||||
}
|
||||
|
||||
return $modelAnchor;
|
||||
}
|
||||
|
||||
private function containsMainDeviceFollowUpAccessoryResidual(string $shopSearchQuery, string $modelAnchor): bool
|
||||
{
|
||||
$queryTokens = $this->tokenizeShopQueryCandidate($shopSearchQuery);
|
||||
if ($queryTokens === []) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$modelTokens = array_fill_keys($this->tokenizeShopQueryCandidate($modelAnchor), true);
|
||||
$accessoryTokens = $this->buildShopQueryTokenSet($this->mergeUniqueStrings(
|
||||
$this->agentRunnerConfig->getNoLlmAccessoryProductRoleKeywords(),
|
||||
$this->agentRunnerConfig->getRequestedAccessoryCodeTerms()
|
||||
));
|
||||
|
||||
foreach ($queryTokens as $token) {
|
||||
if (isset($modelTokens[$token])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($accessoryTokens[$token]) || preg_match('/^\d{1,5}$/u', $token) === 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function guardWeakReferentialShopQueryWithHistoryModelAnchor(
|
||||
|
||||
Reference in New Issue
Block a user