p24
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Commerce\Dto\ShopProductResult;
|
||||
use App\Commerce\SearchRepairService;
|
||||
use App\Commerce\ShopSearchService;
|
||||
use App\Config\AgentRunnerConfig;
|
||||
use App\Config\LanguageCleanupConfig;
|
||||
use App\Context\ContextService;
|
||||
use App\Context\UrlAnalyzer;
|
||||
use App\Infrastructure\OllamaClient;
|
||||
@@ -33,6 +34,7 @@ final readonly class AgentRunner
|
||||
private OllamaClient $ollamaClient,
|
||||
private LoggerInterface $agentLogger,
|
||||
private AgentRunnerConfig $agentRunnerConfig,
|
||||
private LanguageCleanupConfig $languageCleanupConfig,
|
||||
private bool $debug,
|
||||
private bool $logPrompt,
|
||||
private bool $logContext,
|
||||
@@ -2710,7 +2712,7 @@ final readonly class AgentRunner
|
||||
$normalizedPrompt = $this->normalizeRagEvidenceText($prompt);
|
||||
$stopTerms = [];
|
||||
|
||||
foreach ($this->agentRunnerConfig->getRagEvidenceStopTerms() as $term) {
|
||||
foreach ($this->getRagEvidenceCleanupStopTerms() as $term) {
|
||||
$term = $this->normalizeRagEvidenceText($term);
|
||||
if ($term !== '') {
|
||||
$stopTerms[$term] = true;
|
||||
@@ -2743,6 +2745,35 @@ final readonly class AgentRunner
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/** @return string[] */
|
||||
private function getRagEvidenceCleanupStopTerms(): array
|
||||
{
|
||||
return $this->mergeUniqueStrings(
|
||||
$this->languageCleanupConfig->getStopWordsForProfile($this->agentRunnerConfig->getRagEvidenceCleanupProfile()),
|
||||
$this->agentRunnerConfig->getRagEvidenceStopTerms()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $left
|
||||
* @param string[] $right
|
||||
* @return string[]
|
||||
*/
|
||||
private function mergeUniqueStrings(array $left, array $right): array
|
||||
{
|
||||
$out = [];
|
||||
foreach (array_merge($left, $right) as $item) {
|
||||
$item = trim((string) $item);
|
||||
if ($item === '' || isset($out[$item])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$out[$item] = $item;
|
||||
}
|
||||
|
||||
return array_values($out);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string[]>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user