ParsesTextResponses
trait ParsesTextResponses
Traits
Methods
Decode a structured output payload, tolerating markdown code fences.
Join reasoning blocks, separating each block with a blank line.
Validate the OpenAI response data.
Parse the OpenAI response data into a single step response.
Extract the text content from the output array.
Extract the reasoning text from the output array.
Extract citations from the output array.
Extract the ordered response output for full-history replay.
Extract the provider-hosted tool items from the output array.
Extract usage data from the response.
Extract usage data from an image generation response.
Extract and map the finish reason from the response.
Map tool calls with their associated reasoning blocks.
Details
in
DecodesStructuredOutput at line 12
protected array
decodeStructuredOutput(string|null $text)
Decode a structured output payload, tolerating markdown code fences.
in
JoinsReasoning at line 16
static protected string
joinReasoning(iterable $blocks)
Join reasoning blocks, separating each block with a blank line.
at line 31
protected void
validateTextResponse(array $data)
Validate the OpenAI response data.
at line 55
protected StepResponse
parseTextResponse(array $data, Provider $provider, bool $structured)
Parse the OpenAI response data into a single step response.
at line 80
protected string
extractText(array $output)
Extract the text content from the output array.
at line 102
protected string
extractReasoning(array $output)
Extract the reasoning text from the output array.
at line 117
protected Collection
extractCitations(array $output)
Extract citations from the output array.
at line 150
protected array
extractReplayBlocks(array $output)
Extract the ordered response output for full-history replay.
at line 160
protected array
extractProviderToolCalls(array $output)
Extract the provider-hosted tool items from the output array.
at line 173
protected TextUsage
extractUsage(array $data)
Extract usage data from the response.
at line 189
protected ImageUsage
extractImageUsage(array $data)
Extract usage data from an image generation response.
at line 205
protected FinishReason
extractFinishReason(array $data)
Extract and map the finish reason from the response.
at line 237
protected array
mapToolCallsWithReasoning(array $output)
Map tool calls with their associated reasoning blocks.