diff --git a/src/Responses/Chat/CreateResponseChoice.php b/src/Responses/Chat/CreateResponseChoice.php index 21cac796..afba706a 100644 --- a/src/Responses/Chat/CreateResponseChoice.php +++ b/src/Responses/Chat/CreateResponseChoice.php @@ -19,7 +19,7 @@ private function __construct( public static function from(array $attributes): self { return new self( - $attributes['index'], + $attributes['index'] ?? 0, CreateResponseMessage::from($attributes['message']), $attributes['finish_reason'] ?? null, ); diff --git a/src/Responses/Chat/CreateStreamedResponseChoice.php b/src/Responses/Chat/CreateStreamedResponseChoice.php index 6e4f7886..5017398e 100644 --- a/src/Responses/Chat/CreateStreamedResponseChoice.php +++ b/src/Responses/Chat/CreateStreamedResponseChoice.php @@ -19,7 +19,7 @@ private function __construct( public static function from(array $attributes): self { return new self( - $attributes['index'], + $attributes['index'] ?? 0, CreateStreamedResponseDelta::from($attributes['delta']), $attributes['finish_reason'] ?? null, ); diff --git a/src/Responses/Completions/CreateResponseChoice.php b/src/Responses/Completions/CreateResponseChoice.php index 300c238b..aaba6918 100644 --- a/src/Responses/Completions/CreateResponseChoice.php +++ b/src/Responses/Completions/CreateResponseChoice.php @@ -21,7 +21,7 @@ public static function from(array $attributes): self { return new self( $attributes['text'], - $attributes['index'], + $attributes['index'] ?? 0, $attributes['logprobs'] ? CreateResponseChoiceLogprobs::from($attributes['logprobs']) : null, $attributes['finish_reason'], );