Skip to content

Commit ddb875d

Browse files
committed
Support OutputReasoningSummary in ContentPart
Import OutputReasoningSummary and extend the ContentPart $part union type to include it. Update the from() factory to handle 'summary_text' parts by constructing an OutputReasoningSummary, and add a default fallback to map unknown part types into an output_text-like structure. This enables streaming responses to include reasoning-summary content parts.
1 parent 968fe79 commit ddb875d

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/Responses/Responses/Streaming/ContentPart.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use OpenAI\Responses\Meta\MetaInformation;
1212
use OpenAI\Responses\Responses\Output\OutputMessageContentOutputText;
1313
use OpenAI\Responses\Responses\Output\OutputMessageContentRefusal;
14+
use OpenAI\Responses\Responses\Output\OutputReasoningSummary;
1415
use OpenAI\Testing\Responses\Concerns\Fakeable;
1516

1617
/**
@@ -36,7 +37,7 @@ private function __construct(
3637
public readonly int $contentIndex,
3738
public readonly string $itemId,
3839
public readonly int $outputIndex,
39-
public readonly OutputMessageContentOutputText|OutputMessageContentRefusal $part,
40+
public readonly OutputMessageContentOutputText|OutputMessageContentRefusal|OutputReasoningSummary $part,
4041
private readonly MetaInformation $meta,
4142
) {}
4243

@@ -48,6 +49,12 @@ public static function from(array $attributes, MetaInformation $meta): self
4849
$part = match ($attributes['part']['type']) {
4950
'output_text' => OutputMessageContentOutputText::from($attributes['part']),
5051
'refusal' => OutputMessageContentRefusal::from($attributes['part']),
52+
'summary_text' => OutputReasoningSummary::from($attributes['part']),
53+
default => OutputMessageContentOutputText::from([
54+
'type' => $attributes['part']['type'],
55+
'text' => $attributes['part']['text'] ?? '',
56+
'annotations' => $attributes['part']['annotations'] ?? [],
57+
]),
5158
};
5259

5360
return new self(

0 commit comments

Comments
 (0)