fix shop research intent fix 2
This commit is contained in:
@@ -127,6 +127,7 @@ final readonly class AgentRunner
|
||||
commerceHistoryContext: $commerceHistoryContext,
|
||||
userId: $userId
|
||||
);
|
||||
$usedResolvedOptimizedShopQuery = $optimizedShopQuery !== '' && $shopSearchQuery === $optimizedShopQuery;
|
||||
|
||||
if ($shopSearchQuery === '') {
|
||||
$this->agentLogger->info('Commerce search skipped because no concrete shop query could be resolved', [
|
||||
@@ -157,7 +158,7 @@ final readonly class AgentRunner
|
||||
$this->buildShopSearchMetaMessage(
|
||||
query: $shopQueryPreview->searchText !== '' ? $shopQueryPreview->searchText : $shopSearchQuery,
|
||||
commerceIntent: $commerceIntent,
|
||||
usedOptimizedQuery: $optimizedShopQuery !== '',
|
||||
usedOptimizedQuery: $usedResolvedOptimizedShopQuery,
|
||||
originalQuery: $shopSearchQuery
|
||||
),
|
||||
'meta'
|
||||
@@ -166,7 +167,7 @@ final readonly class AgentRunner
|
||||
$this->agentLogger->info('Commerce search prepared', [
|
||||
'userId' => $userId,
|
||||
'commerceIntent' => $commerceIntent,
|
||||
'usedOptimizedShopQuery' => $optimizedShopQuery !== '',
|
||||
'usedOptimizedShopQuery' => $usedResolvedOptimizedShopQuery,
|
||||
'optimizedShopQuery' => $optimizedShopQuery,
|
||||
'shopSearchQuery' => $shopSearchQuery,
|
||||
'hasCommerceHistoryContext' => $commerceHistoryContext !== '',
|
||||
@@ -482,7 +483,7 @@ final readonly class AgentRunner
|
||||
return [];
|
||||
}
|
||||
|
||||
if (preg_match_all('/^Question:\s*(.+)$/mi', $history, $matches) !== 1) {
|
||||
if (preg_match_all('/^Question:\s*(.+)$/mi', $history, $matches) < 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -723,11 +724,20 @@ final readonly class AgentRunner
|
||||
string $commerceHistoryContext,
|
||||
string $userId
|
||||
): string {
|
||||
if ($optimizedShopQuery !== '' && !$this->isMetaOnlyShopQuery($optimizedShopQuery)) {
|
||||
$promptIsMetaOnly = $this->isMetaOnlyShopQuery($prompt);
|
||||
|
||||
/**
|
||||
* A pure meta command such as "suche im shop" has no own product
|
||||
* semantics. In that case the LLM optimizer must not be trusted as the
|
||||
* primary source because it can copy instruction terms from the query
|
||||
* prompt itself (for example "Shopware 6"). Resolve meta commands
|
||||
* deterministically from the recent conversation instead.
|
||||
*/
|
||||
if (!$promptIsMetaOnly && $optimizedShopQuery !== '' && !$this->isMetaOnlyShopQuery($optimizedShopQuery)) {
|
||||
return $optimizedShopQuery;
|
||||
}
|
||||
|
||||
if (!$this->isMetaOnlyShopQuery($prompt)) {
|
||||
if (!$promptIsMetaOnly) {
|
||||
return $prompt;
|
||||
}
|
||||
|
||||
@@ -837,7 +847,7 @@ final readonly class AgentRunner
|
||||
$value = mb_strtolower(trim($value), 'UTF-8');
|
||||
$value = str_replace(['-', '/', '_'], ' ', $value);
|
||||
|
||||
if (preg_match_all('/\d+(?:[,.]\d+)?|[\p{L}\p{N}]+/u', $value, $matches) !== 1) {
|
||||
if (preg_match_all('/\d+(?:[,.]\d+)?|[\p{L}\p{N}]+/u', $value, $matches) < 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
@@ -415,6 +415,12 @@ final class AgentRunnerConfig
|
||||
'im',
|
||||
'in',
|
||||
'nach',
|
||||
'danach',
|
||||
'dazu',
|
||||
'damit',
|
||||
'dafür',
|
||||
'dafuer',
|
||||
'hierzu',
|
||||
'den',
|
||||
'die',
|
||||
'das',
|
||||
|
||||
Reference in New Issue
Block a user