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 OpenRouter response data.
Parse the OpenRouter response data into a single step response.
Extract the reasoning text from an assistant message.
Extract the reasoning details to replay with the message's tool calls.
Extract URL citations from the message annotations array.
Extract usage data from the response.
Extract and map the finish reason from the response.
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 32
protected void
validateTextResponse(array $data)
Validate the OpenRouter response data.
at line 58
protected StepResponse
parseTextResponse(array $data, Provider $provider, bool $structured)
Parse the OpenRouter response data into a single step response.
at line 99
protected string
extractReasoning(array $message)
Extract the reasoning text from an assistant message.
at line 116
protected array
extractReasoningDetails(array $message)
Extract the reasoning details to replay with the message's tool calls.
at line 126
protected Collection
extractCitations(array $message)
Extract URL citations from the message annotations array.
at line 149
protected TextUsage
extractUsage(array $data)
Extract usage data from the response.
at line 165
protected FinishReason
extractFinishReason(array $choice)
Extract and map the finish reason from the response.