p81+81
This commit is contained in:
@@ -5648,6 +5648,10 @@ final readonly class AgentRunner
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$this->shouldShowRenderedFollowUpAction($item, $context, $actionPrompt)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = mb_strtolower($label . "\n" . $actionPrompt, 'UTF-8');
|
||||
if (isset($seenActionKeys[$key])) {
|
||||
continue;
|
||||
@@ -5702,6 +5706,37 @@ final readonly class AgentRunner
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $item
|
||||
* @param array{shop_query:string, shop_price_query:string, answer_has_price:bool, answer_text:string, answer_anchor:string, answer_detail_score:int, role_counts:array<string,int>} $context
|
||||
*/
|
||||
private function shouldShowRenderedFollowUpAction(array $item, array $context, string $renderedPrompt): bool
|
||||
{
|
||||
if (!$this->optionalFollowUpActionBool($item, 'hide_when_material_query_matches_current')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$currentQuery = $this->normalizeShopQueryForComparison($context['shop_query']);
|
||||
if ($currentQuery === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
$materialQueryTemplate = isset($item['material_query_template']) && is_scalar($item['material_query_template'])
|
||||
? trim((string) $item['material_query_template'])
|
||||
: '';
|
||||
|
||||
$materialQuery = $materialQueryTemplate !== ''
|
||||
? $this->renderFollowUpActionPrompt($materialQueryTemplate, $context)
|
||||
: $renderedPrompt;
|
||||
|
||||
$materialQuery = $this->normalizeShopQueryForComparison($materialQuery);
|
||||
if ($materialQuery === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $materialQuery !== $currentQuery;
|
||||
}
|
||||
|
||||
private function optionalFollowUpActionBool(array $item, string $key): bool
|
||||
{
|
||||
if (!array_key_exists($key, $item)) {
|
||||
|
||||
Reference in New Issue
Block a user