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)) {
|
||||
|
||||
@@ -543,7 +543,7 @@ final class ChatMessagesConfig
|
||||
'prompt' => $prompt,
|
||||
];
|
||||
|
||||
foreach (['action_type', 'target_role', 'hide_when_answer_detail_score_at_least'] as $optionalKey) {
|
||||
foreach (['action_type', 'target_role', 'hide_when_answer_detail_score_at_least', 'material_query_template'] as $optionalKey) {
|
||||
if (isset($item[$optionalKey]) && is_scalar($item[$optionalKey])) {
|
||||
$optionalValue = trim((string) $item[$optionalKey]);
|
||||
if ($optionalValue !== '') {
|
||||
@@ -552,8 +552,10 @@ final class ChatMessagesConfig
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists('requires_answer_anchor', $item) && (is_bool($item['requires_answer_anchor']) || is_scalar($item['requires_answer_anchor']))) {
|
||||
$action['requires_answer_anchor'] = $item['requires_answer_anchor'];
|
||||
foreach (['requires_answer_anchor', 'hide_when_material_query_matches_current'] as $optionalBoolKey) {
|
||||
if (array_key_exists($optionalBoolKey, $item) && (is_bool($item[$optionalBoolKey]) || is_scalar($item[$optionalBoolKey]))) {
|
||||
$action[$optionalBoolKey] = $item[$optionalBoolKey];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($item['hide_when_answer_matches_any']) && is_array($item['hide_when_answer_matches_any'])) {
|
||||
|
||||
Reference in New Issue
Block a user