$receipt `model`, `total_tokens`, `duration_ms`, as the pipeline's receipt names them, and `tool_calls`, a count (MessageBubble takes it from the reply's meta) */ public function __construct(private array $receipt) {} public function render(): string { $parts = []; $model = (string) ($this->receipt['model'] ?? ''); if ($model !== '') { $parts[] = $this->e($model); } $tokens = (int) ($this->receipt['total_tokens'] ?? 0); if ($tokens > 0) { /* translators: %s: a token count */ $parts[] = $this->e(sprintf(__('%s tokens', 'alpaca-bot'), number_format_i18n($tokens))); } $ms = (int) ($this->receipt['duration_ms'] ?? 0); if ($ms > 0) { /* translators: %s: seconds to one decimal */ $parts[] = $this->e(sprintf(__('%s s', 'alpaca-bot'), number_format_i18n(round($ms / 1000, 1), 1))); } $tools = (int) ($this->receipt['tool_calls'] ?? 0); if ($tools > 0) { /* translators: %s: how many tool calls the reply made */ $parts[] = $this->e(sprintf(_n('%s tool', '%s tools', $tools, 'alpaca-bot'), number_format_i18n($tools))); } return $this->tag('footer', ['class' => 'ab-receipt'], implode(' · ', $parts)); } }