, token_logprobs: array, top_logprobs: array|null, text_offset: array}|null, finish_reason: string|null} $attributes */ public static function from(array $attributes): self { return new self( $attributes['text'], $attributes['index'], $attributes['logprobs'] ? CreateResponseChoiceLogprobs::from($attributes['logprobs']) : null, $attributes['finish_reason'], ); } /** * @return array{text: string, index: int, logprobs: array{tokens: array, token_logprobs: array, top_logprobs: array|null, text_offset: array}|null, finish_reason: string|null} */ public function toArray(): array { return [ 'text' => $this->text, 'index' => $this->index, 'logprobs' => $this->logprobs !== null ? $this->logprobs->toArray() : null, 'finish_reason' => $this->finishReason, ]; } }