$choices * @param list $messageHistory */ public function __construct( private readonly array $choices = [], private readonly array $messageHistory = [], ) { } /** * @return list */ public function getChoices(): array { return $this->choices; } /** * @return list */ public function getMessageHistory(): array { return $this->messageHistory; } public function getFirstChoice(): ?Choice { if (empty($this->choices)) { return null; } return $this->choices[0]; } public function getContent(): ?string { $firstChoice = $this->getFirstChoice(); if ($firstChoice === null) { return null; } return $firstChoice->getContent(); } /** * @return list */ public function getToolCalls(): array { $toolCalls = []; foreach ($this->choices as $choice) { if (!empty($choice->getToolCalls())) { foreach ($choice->getToolCalls() as $toolCall) { $toolCalls[] = $toolCall; } } } return $toolCalls; } }