patch 17
This commit is contained in:
@@ -1653,6 +1653,13 @@ final readonly class AgentRunner
|
||||
|
||||
$haystack = $this->normalizeRagEvidenceText(implode("\n\n", array_map('strval', $knowledgeChunks)));
|
||||
|
||||
if (
|
||||
$this->isAggregateRagEvidenceQuery($prompt)
|
||||
&& !$this->containsAnyRagEvidenceTerm($haystack, $this->agentRunnerConfig->getRagEvidenceAggregateEvidenceTerms())
|
||||
) {
|
||||
return 'weak';
|
||||
}
|
||||
|
||||
foreach ($needles as $needleGroup) {
|
||||
foreach ($needleGroup as $needle) {
|
||||
if ($this->containsRagEvidenceTerm($haystack, $needle)) {
|
||||
@@ -1687,6 +1694,37 @@ final readonly class AgentRunner
|
||||
};
|
||||
}
|
||||
|
||||
private function isAggregateRagEvidenceQuery(string $prompt): bool
|
||||
{
|
||||
$normalizedPrompt = $this->normalizeRagEvidenceText($prompt);
|
||||
|
||||
if ($normalizedPrompt === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this->agentRunnerConfig->getRagEvidenceAggregateQueryPatterns() as $pattern) {
|
||||
if (@preg_match($pattern, $normalizedPrompt) === 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $terms
|
||||
*/
|
||||
private function containsAnyRagEvidenceTerm(string $haystack, array $terms): bool
|
||||
{
|
||||
foreach ($terms as $term) {
|
||||
if ($this->containsRagEvidenceTerm($haystack, $term)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string[]>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user